我正在编写一个用PHP编写的脚本,它将收集带有特定标签的帖子数量。我找到了正确的api here,但它似乎对我不起作用。我通过身份验证peace并收到一个acnes-token但是当我尝试使用它时,我收到错误消息:
{“meta”:{“error_type”:“OAuthAccessTokenException”,“code”:400,“error_message”:“提供的access_token无效。”}}
这是页面instagram可以在验证后将用户重定向到:
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
echo $code = $_GET["code"];
$content = get_data("https://api.instagram.com/v1/tags/sweden?access_token=".$code) or die("could not open stream");
echo $content;
?>
坦克得到任何帮助!
答案 0 :(得分:3)
$_GET['code']
不访问令牌。
您必须使用该代码从https://api.instagram.com/oauth/access_token
请求访问令牌。
请参阅“第三步:请求access_token”in the docs。