2015-12-25 89 views
1

我已经获得媒体ID列表。例如。如何从媒体ID获得instagram帖子的详细信息

$ media_id = 1147661250940270414_242644508

现在,我已经保存的介质ID。我现在想用Web服务立即获取其他详细信息。下面是我试过的,但没有运气。

$url = 'https://api.instagram.com/v1/media/'.$media_id.'?access_token='.$myaccess_token; 
$response = file_get_contents($url); 
$response = json_decode($response); 
print_r($response); 

Reference from instagram documentation。我怎么能调试? 注意:我已启用curl。上面不打印任何东西。

同时打印$url并浏览打印json数据。

回答

2

你究竟错了什么?它与我的访问令牌和media_id完美配合。结果是:

stdClass Object ([meta] => stdClass Object ([code] => 200) [data] => stdClass Object ([attribution] => [tags] => Array ([0] => summer [1] => merrychristmas [2] => love [3] => christmas [4] => family) [type] => image [location] => [comments] => stdClass Object ([count] => 0 [data] => Array ()) [filter] => Rise [created_time] => 1451031904 [link] => https://www.instagram.com/p/_tT9PAxndO/ [likes] => stdClass Object ([count] => 6 [data] => Array ([0] => stdClass Object ([username] => nedz3388 [profile_picture] => https://igcdn-photos-e-a.akamaihd.net/hphotos-ak-xft1/t51.2885-19/11296865_494353930737804_199912633_a.jpg [id] => 245135480 [full_name] => Nerida Cole) [1] => stdClass Object ([username] => ashleyhughesxixii [profile_picture] => https://igcdn-photos-e-a.akamaihd.net/hphotos-ak-xfp1/t51.2885-19/s150x150/12292658_1933982046828004_675035842_a.jpg [id] => 8121980 [full_name] => AshleyHughes) [2] => stdClass Object ([username] => beccao88 [profile_picture] => https://igcdn-photos-e-a.akamaihd.net/hphotos-ak-xtp1/t51.2885-19/s150x150/11374242_179260799080196_1224064424_a.jpg [id] => 145580378 [full_name] => Rebecca Ormond) [3] => stdClass Object ([username] => love_the_shred [profile_picture] => https://igcdn-photos-h-a.akamaihd.net/hphotos-ak-xat1/t51.2885-19/s150x150/10932468_1606801716246599_1519881141_a.jpg [id] => 248027596 [full_name] => Tony Young))) [images] => stdClass Object ([low_resolution] => stdClass Object ([url] => https://scontent.cdninstagram.com/hphotos-xfp1/t51.2885-15/s320x320/e35/12357934_1011207135587426_1185326237_n.jpg [width] => 320 [height] => 320) [thumbnail] => stdClass Object ([url] => https://scontent.cdninstagram.com/hphotos-xfp1/t51.2885-15/s150x150/e35/12357934_1011207135587426_1185326237_n.jpg [width] => 150 [height] => 150) [standard_resolution] => stdClass Object ([url] => https://scontent.cdninstagram.com/hphotos-xfp1/t51.2885-15/s640x640/sh0.08/e35/12357934_1011207135587426_1185326237_n.jpg [width] => 640 [height] => 640)) [users_in_photo] => Array () [caption] => stdClass Object ([created_time] => 1451031904 [text] => Merry Christmas to all xx #christmas #merrychristmas #family #love #summer [from] => stdClass Object ([username] => brooklyne91 [profile_picture] => https://igcdn-photos-a-a.akamaihd.net/hphotos-ak-xaf1/t51.2885-19/s150x150/12276893_1526872547628928_24812970_a.jpg [id] => 242644508 [full_name] => Broooke Ellis) [id] => 1147661252576048439) [user_has_liked] => [id] => 1147661250940270414_242644508 [user] => stdClass Object ([username] => brooklyne91 [profile_picture] => https://igcdn-photos-a-a.akamaihd.net/hphotos-ak-xaf1/t51.2885-19/s150x150/12276893_1526872547628928_24812970_a.jpg [id] => 242644508 [full_name] => Broooke Ellis))) 

然后,您可以将这些数据单独分解为您的方式。

+0

是的,我也在寻找我出错的地方。即使在浏览器上打印url也会给我json数据 –

+0

这就是结果。你想获得JSON数据,那么你必须使用你在PHP中的知识来分解它。 – Lachie

+0

在解码json之前,'$ response = file_get_contents($ url);'什么也没有返回。 –

相关问题