【问题标题】:POST instagram api follow with cURL PHPPOST instagram api 跟随 cURL PHP
【发布时间】: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


【解决方案1】:

您可能已为您的 Instagram 客户端应用启用强制签名请求。因此,您需要使用签名标头发出请求。欲了解更多详情,请访问以下https://instagram.com/developer/restrict-api-requests/。他们在那里提到了签名请求的常见响应。我们应该将 access_token 用于某些端点。并且您正在尝试发出 post 请求,在发出 post 请求之前,请确保您有权在该端点上发出 post 请求。 你回复的原因, 缺少标头 {"code": 403, "error_type": "OAuthForbiddenException", "error_message": "Invalid header: X-Insta-Forwarded-For is required for this operation"}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-04
    • 1970-01-01
    • 1970-01-01
    • 2018-05-02
    • 2016-08-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多