¡Hi!
I'm trying to post with instagram API. I have one random valid access_token and I'm trying to follow someone only with the access_token using php and cURL, is it possible?
My PHP CODE:
$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);
And i get this error:
{"code": 403, "error_type": "OAuthForbiddenException", "error_message": "Invalid header: X-Insta-Forwarded-For is required for this operation"}
I read that I can do actions (follow, like) with only access_token, is it truth?
Thanks!
You might have enabled enforce signed requests for your instagram client app. So you need to make request with a signed header. For more details visit the following https://instagram.com/developer/restrict-api-requests/ . There they mentioned the common responses for signed requests. We should use access_token for some endpoints. And you are trying to make a post request, before making post request make sure that you have the permission to make a post request on that endpoint. The reason for your response, Header is missing {"code": 403, "error_type": "OAuthForbiddenException", "error_message": "Invalid header: X-Insta-Forwarded-For is required for this operation"}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With