Here is my code to json decode picasa api results, but it always Warning: Invalid argument supplied for foreach(), Where is the problem? Thanks.
<?php
header('Content-type:text/html; charset=utf-8');
$url="http://picasaweb.google.com/data/feed/base/all?alt=json&kind=photo&access=public&filter=1&q=usa&imgor=landscape&max-results=50&hl=en";
$json = file_get_contents($url);
$data = json_decode($body, true);
foreach ($data['feed']['entry'] as $result){
echo html_entity_decode($result->content->src, ENT_QUOTES, 'UTF-8');
echo html_entity_decode($result['updated']['$t'], ENT_QUOTES, 'UTF-8');
}
?>
You are using a wrong variable:
It should be $json instead of $body.
You used json_decode(, true) so it converts all objects to associative arrays. But here you use object-notation to access your data which might result in another error: