MilliR Posted September 2, 2014 Share Posted September 2, 2014 I am a noob in api so please bear with me. I tried google searching for 1 hour but I can't understand anything from the results. Currently, I have an API in kimono with the given example data : { "name": "Summoners-Details", "count": 31, "frequency": "On demand", "version": 7, "newdata": false, "lastrunstatus": "success", "thisversionrun": "Tue Sep 02 2014 02:34:07 GMT+0000 (UTC)", "lastsuccess": "Tue Sep 02 2014 02:34:07 GMT+0000 (UTC)", "stats": { "retriedUrls": [], "failedUrls": [], "successful": 1, "rows": 31, "retried": 0, "failed": 0, "duration": 1894 }, "results": { "rank": [ { "division": "Wukong's Lancers Silver-tier II" } ] } } Here is the php code I am trying to use to get the division data, but I am getting nothing! : <?php $request = "https://www.kimonolabs.com/api/c6qj1oc?apikey=xxxxxxxxxxxxxxxxxx"; $response = file_get_contents($request); $results = json_decode($response, TRUE); $division = $results->{'results'}->{'rank'}->{'division'}; echo $division; ?> What am I doing wrong here?? Link to comment https://forums.phpfreaks.com/topic/290791-using-kimono-api-data-in-php/ Share on other sites More sharing options...
mac_gyver Posted September 2, 2014 Share Posted September 2, 2014 in your code, $results will be an array, not an object. if you use echo '<pre>',print_r($results,true),</pre>;, you can see what the structure of the array is. Link to comment https://forums.phpfreaks.com/topic/290791-using-kimono-api-data-in-php/#findComment-1489613 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.