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?? Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.