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 Syropian: 2/9/2015 2:19:52 AM
3

Simple curl request to fetch info for a certain player

Trying to get my head around the API, by making a simple CURL call. I tried: [quote]curl -H "X-API-Key: <myapikey>" http://www.bungie.net/platform/Destiny/SearchDestinyPlayer/1/Syropian/[/quote] but I just got this back: [quote]{"Response":[{"iconPath":"/img/theme/destiny/icons/icon_xbl.png","membershipType":1,"membershipId":"4611686018439274225","displayName":"Syropian"}],"ErrorCode":1,"ThrottleSeconds":0,"ErrorStatus":"Success","Message":"Ok","MessageData":{}}[/quote] Any ideas where I went wrong?

Posting in language:

 

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

  • Edited by Godly: 2/9/2015 4:20:47 PM
    Hey, I use file_get_contents in a function like this: [quote] function getUrlContent($url) { $context = stream_context_create(array( 'https' => array( 'method' => 'GET', 'header' => "Host: www.YourURL.com\r\nX-API-Key: YourAPIKey\r\n" ) )); $urlContent = file_get_contents("https://www.bungie.net/" . $url, false, $context); return $urlContent; }[/quote] Your response looks good actually! You need to extract the membershipId (4611686018439274225) and use that to query further. Here's some more code to give you an idea: [quote]$url = "Platform/Destiny/SearchDestinyPlayer/" . $v_platform . "/" . $v_userId . "/"; $urlContent = getUrlContent($url); $jsonObj = json_decode($urlContent, true); $responseObj = $jsonObj['Response'][0]; $this->membershipId = $responseObj['membershipId']; if($this->membershipId == null){ return; //This will return basic info for that gamertag $url = "Platform/Destiny/Tiger" . $platformStr . "/Account/" . $membershipId . "/"; $urlContent = getUrlContent($url); $jsonObj = json_decode($urlContent, true); $dataObj = $jsonObj['Response']['data']; }[/quote]

    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
    • Did you try turning it off and back on?

      Posting in language:

       

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

      3 Replies
      • Uhh...

        Posting in language:

         

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

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