Decode json string returned from Flickr API using PHP, curl
Posted
by Globalz
on Stack Overflow
See other posts from Stack Overflow
or by Globalz
Published on 2010-05-02T04:23:13Z
Indexed on
2010/05/02
4:27 UTC
Read the original article
Hit count: 406
Im trying to decode a json string returned from flickr within my PHP code. Im using CURL but it keeps returning a string even when I wrap json_decode() around the json sring variable. Any ideas?
$api_key = '####';
$photoset_id = '###';
$query = 'http://api.flickr.com/services/rest/?&method=flickr.photosets.getPhotos&api_key='.$api_key.'&photoset_id='.$photoset_id.'&extras=url_o,url_t&format=json&jsoncallback=1';
$ch = curl_init(); // open curl session
// set curl options
curl_setopt($ch, CURLOPT_URL, $query);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch); // execute curl session
curl_close($ch); // close curl session
var_dump(json_decode($data));
© Stack Overflow or respective owner