2

I'm trying to automate my instagram feed (in future extending to more users). To achieve that, im using:

  • Instagram basic display: to get access token for a certain user, permissions and then access to read-only data (followers, posts, etc). But this application does not support posting anything, just read operations.
  • Instagram graph API: I pretend to use this to actually post on instagram, but after reading the documentation and other questions in stackoverflow, i can't get any clue on how to post an image/video.

Also, as mentioned in the docs: share on news section it seems to be posible to post, but not from my app, it opens instagram app (which also shows compatibility with mobile apps only).

My last guess is that it's maybe posible by using facebook's graph API facebook's docs, where:

curl -i -X POST \ "https://graph.facebook.com/{your-page-id}/feed?message=Awesome!&access_token={your-page-access-token}"

it's used to post.

I've tried to use same format but on instagram's API:

curl -i -X POST \ "https://graph.instagram.com/{your-page-id}/feed?message=Awesome!&access_token={your-page-access-token}"

I got response from server (what gives me some hope that at least the endpoint exists) but it was an error response with unauthorized code.

Anyone knows how to post an image using the graph API? Is it even posible?

If you need any more info please ask for it in a comment!

Thanks!

1 Answers1

4

It is now possible to POST contents (images, videos inclusive) to your instagram feed using Instagram Content Publishing API(Visit their website for more details).

There exist many restrictions/limitations for posting images as well:

  • Can only be used to publish to business IG User accounts; Creator IG User accounts are not supported.
  • Accounts are limited to 25 API-published posts within a 24 hour period.
  • JPEG is the only image format supported. Extended JPEG formats such as MPO and JPS are not supported.
  • Stories are not supported.
  • Shopping tags are not supported.
  • Branded content tags are not supported.
  • Filters are not supported.
  • Multi-image posts are not supported.

Publishing photos is a two-step process:

theycallmepix
  • 474
  • 4
  • 13
  • Hi! Sorry for the delay, I was on vacation. When trying to add permissions to my scope, API returns invalid scope error as: `{"error_type": "OAuthException", "code": 400, "error_message": "Invalid scope: ['ads_management', 'business_management', 'instagram_basic', 'instagram_content_publish', 'pages_read_engagement', 'user_media', 'user_profile']"}`. [docs](https://developers.facebook.com/docs/instagram-api/guides/content-publishing/#publish-photos) – Agustin L. Lacuara Feb 08 '21 at 13:17
  • Hey, I think you've to renew the token. Just renew it, then extend the date for about 3 months atleast(permanent is possible), try again:) – theycallmepix May 21 '21 at 07:56
  • @AgustinL.Lacuara , you first need to create an app under Myapp section in (https://developer.facebook.com). Request the necessary permissions by submitting a video for review. Once the app is approved, you can work with Graph API, until then Graph API doesn't work – Srinivasan Oct 18 '21 at 09:47
  • It is very strange, I cannot use a media which I have locally... are there any workarounds to image_url querry param? – Bionix1441 Jun 20 '23 at 15:37
  • @Bionix1441 - Yes, you can use ngrok for this. I have done it and its pretty easy to do. You need to install ngrok then use the subprocess module to run ngrok so you can do a quick temporary serve of your local picture. (I am not providing code details. I am just letting you know that a quick search on how to use ngrok should resolve your inquiry) – PythonKiddieScripterX Jun 27 '23 at 21:57