我正在编写一个用php编写的脚本,该脚本将收集带有特定主题标签的帖子数量。我在这里找到了正确的 api,但它似乎对我不起作用。我经历了身份验证和平并收到一个痤疮令牌,但是当我尝试使用它时,我收到错误消息:
{"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;
?>
坦克满了任何帮助!
$_GET['code']
不是访问令牌。
您必须使用该代码从 https://api.instagram.com/oauth/access_token
请求访问令牌。
请参阅文档中的"步骤 3:请求access_token"。