# Post to Instagram
Now that we have all the tokens, we can start creating posts and sending them to Instagram using the Graph API. The first step is to get the instagram page ID, yes its different from the Facebook page ID.
# Instagram Page ID
You will need:
- Facebook page ID: pageID
- Long life page access token: pageAccessToken
Send a GET command:
https://graph.facebook.com/v10.0/<pageID>?fields=instagram_business_account&access_token=<pageAccessToken>
You will get in return:
{
"instagram_business_account": {
"id": "<instagramPageID>"
},
"id": "<pageID>"
}
TIP
You need to convert your Instagram page to a business / professional page and connect it to your facebook page before running this step or you will not get the required results. Sometimes the command only returns the facebook page id - if that happens, double check your connection to the instagram page, and make sure the instagram page has been converted to a business/professional account.
# Post an Image
To post an image, this is what you will need:
- Instagram page ID: instagramPageID
- HTTPS location of the image you want to post (The image that you want to post needs to be saved in a public location that is accesible via a https link): httpsLocation
- A caption for the instagram post: caption
- The Facebook page long life access token: pageAccessToken
Send POST request to the following URL
https://graph.facebook.com/v10.0/<instagramPageID>/media
The Payload should be
{
"image_url": "<httpsLocation>",
"caption": "<caption>",
"access_token": "pageAccessToken"
}
You will get a response with an id, you will need it for the next step.
What you will need:
- Instagram page ID
- Creation ID - from the last step
- Facebook page access token
Send a POST request to the following url:
https://graph.facebook.com/v10.0/<instagramPageID>/media_publish
The payload:
{
"creation_id": "creation_id",
"access_token": "pageAccessToken"
}
Now check your instagram, you should see the image and caption posted.