JavaScript is required to use Bungie.net

#wiki

postato inizialmente in:BungieNetPlatform
9/28/2015 9:59:56 AM
4

Struggling with API access (PHP). Have Key, need help.

Hi there, I've been playing around with the API for a while now but am having issues with the new 'key required' access. I'm new to cURL and REST api, but have a basic php understanding, however I'm struggling since the access update. I've copy and pasted the code from the wiki [url]http://bungienetplatform.wikia.com/wiki/Getting_Started[/url] and replaced 'YOUR -API-KEY-HERE' with my key but keep getting a Trying to get property of non-object error. Is the code still viable now keys are mandatory? What am I doing wrong? Thanks Anthony [quote] Here is my code; <?php $apiKey = 'YOUR-API-KEY-HERE'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://www.bungie.net/platform/Destiny/Manifest/InventoryItem/1274330687/'); 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->data->inventoryItem->itemName; //Gjallarhorn [/quote]
English
#wiki #php #apikey

Lingua:

 

Fate i bravi. Prima di postare date un'occhiata al nostro codice di condotta. Annulla Modifica Crea squadra Invia

  • Is it possible to do this from a local dev environment (read: localhost) and then push your finished product to a live server rather than developing externally?

    Lingua:

     

    Fate i bravi. Prima di postare date un'occhiata al nostro codice di condotta. Annulla Modifica Crea squadra Invia

    2 Risposte
    • It's possible that your server doesn't have curl support. on a temporary php page (because you really don't want bots/nefarious people finding it), use the command phpinfo(). It'll create a page with a *bunch* of information about your php setup and server. If your server is configured for it, you'll likely see a section near the top detailing the configure flags. Mine listed --with-curl in it, along with many other. Additionally, there was a Curl section that detailed the version and which libraries it had access to (ssl, zlib, etc).

      Lingua:

       

      Fate i bravi. Prima di postare date un'occhiata al nostro codice di condotta. Annulla Modifica Crea squadra Invia

      2 Risposte
      • You also need to have x-csrf = $bungled (from the bungie cookies) in the http headers.

        Lingua:

         

        Fate i bravi. Prima di postare date un'occhiata al nostro codice di condotta. Annulla Modifica Crea squadra Invia

        1 Rispondi
        • Modificato da VlakafatakafA: 9/28/2015 11:44:24 AM
          Tested the code on http://phpfiddle.org/ and it worked. Make sure your API key is correct

          Lingua:

           

          Fate i bravi. Prima di postare date un'occhiata al nostro codice di condotta. Annulla Modifica Crea squadra Invia

          1 Rispondi
          Non ti è permesso visualizzare questo contenuto.
          ;
          preload icon
          preload icon
          preload icon