I am trying to use PHP's json_decode function to get a particular value from a json object. Sample code below:
foreach ($streams as &$i) {
$chan = "http://api.justin.tv/api/stream/list.json?channel=" . $i;
$json = file_get_contents($chan); //Turns the gathered file information into a string for searching purposes.
echo $json . " End of json variable.<br>";
$exist = strpos($json, 'name'); // Search the file/json object for the name attribute
if($exist) { // Check to see if a name existed and if so add it to the live streams and get the image.
echo " <a href=\"http://justin.tv/" . $i . "\">" . $i . "</a> <br>";
$liveStreams[$count] = $i;
$json_information = json_decode($json,true);
$image[$count] = $json_information[0]['channel']['image_url_large'];
echo "Image link should appear: " . $image[count];
$count++;
}
}
So What I am trying to do with this is first and foremost gather which streams are active from a list provided earlier in the code. Second, if the stream is live, display a link to a page for it to be viewed(currently the justin.tv stream itself). What currently works is only the live streams will appear with links to them. What I need is to figure out why after decoding I cannot access the image_url_large variable. This is going to be a thumbnail view of the stream eventually.
I have looked at various places for what should have worked and even on stackoverflow I saw the following thread:
I tried doing it like nickf's answer and it still isn't working. Any help would be greatly appreciated as well as staying within the array style instead of going into objects.