php - How can take a value of this json? -
php - How can take a value of this json? -
i want know how take value json.
i must take value "fifa 15" (the field "name").
the content of json (http://xboxapi.com/v2/superdeder/xboxonegames) this:
{ "titles": [ { "lastunlock": "2014-10-11t12:30:30.4788799z", "titleid": 122001257, "serviceconfigid": "64c10100-3d40-49d5-8f1c-c99807459769", "titletype": "liveapp", "platform": "durango", "name": "youtube", "earnedachievements": 3, "currentgamerscore": 0, "maxgamerscore": 0 }, { "lastunlock": "2014-10-28t21:55:44.6766285z", "titleid": 1689264723, "serviceconfigid": "0b430100-23ff-43cd-a287-894f64b02253", "titletype": "dgame", "platform": "durango", "name": "fifa 15", "earnedachievements": 11, "currentgamerscore": 350, "maxgamerscore": 1000 } ], "paginginfo": { "continuationtoken": null, "totalrecords": 2 } }
with normal json succeed take value believe there need of authentication.
this documentation: https://xboxapi.com/documentation.
i utilize php within altervista.
thanks!
you first need sign in @ xboxapi.com xbox gametag, or can create new gametag website. after have done see 'xboxapi api key' on profile page on website, authentication key.
you can utilize illustration curl retrieve info want.
$url = 'https://xboxapi.com/v2/superdeder/xboxonegames'; $headers = array('x-auth: ***your api key here***'); $session = curl_init($url); curl_setopt($session, curlopt_returntransfer, true); curl_setopt($session, curlopt_httpheader, $headers); $response = curl_exec($session); curl_close($session); $myarray = json_decode($response, true); // have json array file called $myarray, // can see what's within array with: echo '<pre>'; var_dump($myarray); echo '</pre>'; //the game fifa15 3rd in games list, retrieve name use: echo $myarray["titles"][2]["name"]; php json authentication xbox
Comments
Post a Comment