【问题标题】:How to get detail of instagram post from media id如何从媒体 ID 获取 Instagram 帖子的详细信息
【发布时间】:2015-12-25 10:03:09
【问题描述】:

我已经获得了媒体id列表。例如。

$media_id = 1147661250940270414_242644508

现在,因为我已经保存了媒体 ID。我现在想使用网络服务立即获取其他详细信息。以下是我尝试过但没有运气的方法。

$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 来自 Instagram 文档。我该如何调试? 注意:我已启用curl。上面没有打印任何内容。

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

【问题讨论】:

    标签: php web-services api instagram-api


    【解决方案1】:

    你到底有什么问题?它与我的访问令牌和您的 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 ) ) )
    

    然后您可以根据自己的喜好单独拆分这些数据。

    【讨论】:

    • 是的,我也在寻找我哪里出错了。即使在浏览器上打印 url 也会给我 json 数据
    • 这就是结果。你想要获取 JSON 数据,那么你必须使用你在 PHP 中的知识来拆分它。
    • 在解码 json 步骤之前,$response = file_get_contents($url); 没有返回任何内容。
    • 我有一个包含您的确切代码的文件,print_r($response); 这一行打印出 JSON 数据。
    • 好的,这里不打印,我想知道为什么在我的情况下它不打印。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-22
    • 1970-01-01
    • 1970-01-01
    • 2014-03-30
    • 1970-01-01
    • 1970-01-01
    • 2016-04-11
    相关资源
    最近更新 更多