views:

95

answers:

2

hi friends i am trying to solve how i can access the halo reach api for get states bungie has released a api for this here is the link http://www.bungie.net/fanclub/statsapi/Group/Resources/Article.aspx?cid=545064

how can i access this service via php and display some stats need help thanks

i am trying like this

 <?php
 require_once('lib/nusoap.php');
 $wsdl  = "http://www.bungie.net/api/reach/ReachApiJson.svc?wsdl";
 $client = new soapclient($wsdl, 'wsdl');
 $parameters['parameters']['apikey'] =   "xxx";
 $result = $client->call("GetGameMetadata", $parameters);
 ?>
A: 

For one thing you should be using reachapisoap.svc (not reachapijson.svc) with nusoap. That being said it says right there in the document header the SOAP is legacy only, and no documentation is being provided.

It's probably better to use the REST API (with JSON - as you've got) which for your purpose (retrieving data only) is going to be trivial (all simple URL requests).

Rudu
can you put me in a direction or give me a little sample code or any artical where i can see
livetolearn
+2  A: 

Consuming JSON in PHP is pretty simple.

<?PHP
$uri = 'http://www.bungie.net/api/reach/reachapijson.svc/game/metadata/xxx';
if (! $json = file_get_contents($uri)){ //cURL can be faster and more flexible, but this ought to work
    trigger_error('API call failed!');
}
if (! $result = json_decode($json)){
    trigger_error('API returned bad data?');
    //maybe log some stuff here, so you can debug.
}
print_r($result); //see what you got.
timdev
can you please tell me how i can do this with curl
livetolearn
i try this code and i try many times with diffrent ways nothing works for me thanks for your help
livetolearn