【发布时间】:2015-05-31 22:57:29
【问题描述】:
¡嗨!
我正在尝试使用 instagram API 发帖。我有一个随机有效的 access_token,我试图使用 php 和 cURL 仅使用 access_token 来关注某人,这可能吗?
我的 PHP 代码:
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL,"https://api.instagram.com/v1/users/<userid>/relationship?access_token=<valid access_token>");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'action=follow');
// grab URL and pass it to the browser
$result = curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
print_r($result);
我得到这个错误:
{"code": 403, "error_type": "OAuthForbiddenException", "error_message": "Invalid header: X-Insta-Forwarded-For is required for this operation"}
我读到我可以仅使用 access_token 执行操作(关注、喜欢),这是真的吗?
谢谢!
【问题讨论】:
-
好吧,我确认我可以只用 access_token 关注某人,那为什么会出现这个错误? :)
标签: php api post curl instagram