JavaScript is required to use Bungie.net

Group Avatar

BungieNetPlatform

"Updates, discussions, and documentation of the BungieNetPlatform API."

Request Join
originally posted in:BungieNetPlatform
Edited by Reflex: 2/11/2016 9:42:03 AM
1

Trouble with API request in PHP

Hi guys. So I'm fairly new to the Destiny API and have little PHP experience so I was following these tutorials: http://bungienetplatform.wikia.com/wiki/Getting_Started & http://web.engr.oregonstate.edu/~walkermi/HowTo3.html When I load the php file, it returns Notice: Trying to get property of non-object in C:\wamp\www\DestinyStats\bnet_api_test.php on line 10. I'm not sure what I'm doing wrong as I copied the code and entered my exact API key. I pasted the code below again for you guys to check. I am using a WAMP setup to test things out locally. I appreciate any suggestions you might have. <?php $apiKey = 'api key goes here'; $ch = curl_init(); https://www.bungie.net/platform/destiny/{MembershipType}/Stats/GetMembershipIdByDisplayName/{DisplayName}'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-API-Key: ' . $apiKey)); $json = json_decode(curl_exec($ch)); echo $json->Response; ?> I was using 1 for MembershipType and my GT for the DisplayName

Posting in language:

 

Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • Hey! Try adding a / at the end of the url. To make sure, dont forget to pass the url to $ch: curl_setopt($ch, CURLOPT_URL, 'url_here'); And I suggest adding the following lines: $info = curl_getinfo($ch); curl_close($ch); This will give you info about the request, it would've told you it was an invalid url and that you should request to the one with a slash at the end.

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

    2 Replies
    You are not allowed to view this content.
    ;
    preload icon
    preload icon
    preload icon