【问题标题】:Instagram API link not working in php fileInstagram API链接在php文件中不起作用
【发布时间】:2016-01-13 21:43:06
【问题描述】:

我正在尝试创建一个网站来显示我朋友的 Instagram 关注者数量和最近的图片。我终于认为我已经想出了如何做到这一点,但我遇到了一个错误。每次我运行我的 php 文件时,我都会得到

stdClass 对象([meta] => stdClass 对象([error_type] => APINotFoundError [code] => 400 [error_message] => 无效媒体 ID))

我运行的代码是:

<?php

function extractData(){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,
"https://api.instagram.com/v1/media/shortcode/D?access_token=*");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 20);

    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}
$activate= extractData();

print_r(json_decode($activate));
?>

我有一个有效的访问密钥,出于安全原因,我刚刚取出了它。

【问题讨论】:

    标签: php json curl instagram stdclass


    【解决方案1】:

    我认为您的端点 URL 不正确。当它应该查看您好友的帐户时,它没有指定任何数据。 有关返回数据,请参阅:https://www.instagram.com/developer/endpoints/users/#get_users

    更改 URL 以匹配正确的用户:

    "https://api.instagram.com/v1/users/{user-id}/?access_token=*");
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-15
    • 2014-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-07
    • 1970-01-01
    相关资源
    最近更新 更多