saddam hussain
saddam hussain

Reputation: 21

how to post on instagram using graph api in php

I am trying to post on instagram using graph api but i am not able to post.

Content Publishing The Content Publishing API is a subset of Instagram Graph API endpoints that allow you to publish IG Media objects on Instagram Business IG Users.

Publishing media objects with this API is a two step process — you first create a media object container, then publish the container.

i try all the code but stil looking for solution

POST graph.facebook.com/17841400008460056/media
  ?image_url=https//www.example.com/images/bronz-fonz.jpg
  &caption=#BronzFonz

i try this one but code is not returning a media object

Returning this kind of error:

Facebook\Exceptions\FacebookResponseException (#3) Application does not have the capability to make this API call. ↵ Caused by: Facebook\Exceptions\FacebookAuthenticationException (#3) Application does not have the capability to make this API call. in /home2/urmemesc/public_html/demoproqaz/src/Facebook/Exceptions/FacebookResponseException.php at line 142

enter image description here

Upvotes: 2

Views: 5498

Answers (2)

NatureLady
NatureLady

Reputation: 81

Besides needing an Instagram business account as stated in another answer, you need to

POST graph.facebook.com/17841400008460056/media
  ?image_url=https//www.example.com/images/bronz-fonz.jpg
  &caption=#BronzFonz

Then you will get a container_id back.

Then you will have to wait until the container is ready to publish to the container. I found it has taken anywhere from 5 minutes to 8 hours for the container to be ready. Has anyone else found this?

You can poll the container as much as you want to check its status with

GET graph.facebook.com/$containerId?access_token=$access_token&fields=status,status_code 

The status returned will look like:

{
  "status": "In Progress: Media is still being processed.",
  "status_code": "IN_PROGRESS",
  "id": "178813296555432"
}

Until it says it's ready to publish (which again is anywhere from instantly to hours).

IMO this is a really bad setup, I wish they would add something to ping us back when it's ready. It's also impossible to schedule a distribution because of the variable time.

Upvotes: 1

otejiri
otejiri

Reputation: 1017

The simple answer is you can't unless you are an Instagram Partner, for now you can't be an instagram partner because registration is in closed beta.

You can get more information from the link below:

https://developers.facebook.com/docs/instagram-api/guides/content-publishing/

UPDATE September 2020

Seems like it is possible now, I haven't tried it yet but the link below seems to suggest possibility

https://developers.facebook.com/docs/graph-api/using-graph-api/

Upvotes: 3

Related Questions