Posts tagged with instagram-api

I'm working on an app where I need to fetch all instagram posts of a user. The user is logged in with Instagram Api with Facebook Login

I get well the id of the instagram business account and the different tokens needed but when I try to fetch the posts there is two possible answers and none of them is the one I want.

If I request https://graph.instagram.com/v21.0/<instagramId>/media?fields=id,children{{media_type,media_product_type,media_url,thumbnail_url,timestamp,like_count,comment_count}},media_product_type,media_type,media_url,thumbnail_url,timestamp,like_count,comments_count&access_token=<token> I receive a 400 answer "this action is unavailable" Which seems normal because the user is logged in through Facebook so I should pass by Facebook graph api.

But when I request https://graph.facebook.com/v21.0/<instagramId>/media?fields=id&access_token=<token> I only fetch the reels not the posts.

Any idea?

I am using instagram graph api, with these permissions(pages_show_list, instagram_basic, pages_read_engagement) and this repository https://github.com/jstolpe/instagram-graph-api-php-sdk

I am able to obtain a long-lived access token and use it to retrieve media and perform other actions, but the token expires after 60 days. I’m looking for a way to refresh it before it expires.

I found this https://developers.facebook.com/docs/instagram-platform/reference/refresh_access_token but when I try this code

GET https://graph.instagram.com/refresh_access_token   ?grant_type=ig_refresh_token   &access_token={long-lived-access-token} 

the output is: "Sorry, this content isn't available right now"

Is there a way to automatically refresh a long-lived access token, or does it need to be manually updated every 59 days?

Additionally, I can’t find any information on how to obtain or add the instagram_graph_user_profile permission.

Does anyone know how to resolve this?

Apologies for what should be a basic question, but i've hit the end of my rope. I'm trying to resurrect an old project that used the instagram API to search for posts based on a given hashtag (long before the graph API). Previously this was very simple to go to the developer page, apply for an API token and then hit the URL. Things have changed massively with the newer graph endpoints and i'm struggling to understand what to do, and hitting bugs/issues with facebooks developer tooling at every step of the way

What I want to do:
Given a hashtag string, find the hashtag id and then poll this endpoint once, lets say, every 30 seconds: https://developers.facebook.com/docs/instagram-platform/instagram-graph-api/reference/ig-hashtag/recent-media

Later I want to try search for comments on these posts too, but that will depend on a few things as I go

Whats wrong:
Every attempt to make use of this (by creating an app on the dashboard, waiting for verification, and generating a token) just keeps returning that the token is invalid, or the account is not valid. Lots of the documentation seems to be out of date and referencing an older setup. Some docs say that this endpoint requires a business account + business app. Although I didn't want to, I migrated my personal instagram account to a business account, and tried to create a business app which is an extremely convoluted process requiring business verification, for simple access to an endpoint. I don't have a business so I can't fully complete this process.

I've tried to ask for help via the meta developer community, but it won't load for many days now:

If I try jump directly into the instagram community section via google, it will load, but I keep getting a popup to say that my profile is incomplete. If I click to complete, it doesn't do anything. If I dismiss it, it just keeps popping up. If I go directly to my profile, it won't let me add anything. The community page won't let me do anything without the profile

I've tried to report a bug via the tool, but it tells me I can't do that here, as this bugs should be directed to the community portal ... which I can't get into

... this has been an EXTREMELY painful experience over the course of several days which has me regretting trying to use instagram again

What I need:
Can someone please provide step-by-step instructions on what I need to do to create the appropriate access token to hit this endpoint. Including the process of creating whichever type of developer app I need in the dashboard.

I don't have a server, a domain, a business, or even a project name ... i'm simply trying to generate a once off access token, hit this endpoint via a project running on my local machine to experiment with an idea. Thanks

I'm facing an issue with the Instagram Graph API where the ID in the webhook data doesn't match the ID returned from the /me endpoint.

I use the /me endpoint to get the Instagram Business ID:

https://graph.instagram.com/me?fields=id,username

This returns 12345 and my username.

When an Instagram user sends a message, the webhook data contains a different recipient ID (67890), which doesn't match the stored ID (12345).

Example Webhook:

{   "object": "instagram",   "entry": [     {       "time": 67890,       "id": "12345400796128930",       "messaging": [         {           "sender": { "id": "981149143905198" },           "recipient": { "id": "67890" },           "timestamp": 1735516966810,           "message": {             "mid": "1bfkwjeb1jk43b1jk43bkj",             "text": "hello hello"           }         }       ]     }   ] } 

The recipient ID (67890) corresponds to the user who authorized my app but is not the same as the ID from the /me endpoint.

Is Instagram sending an ID that can't be looked up via the access token? This ID (67890) is persistent across multiple webhook requests.

In our application, we currently use the Instagram Display API, but it will be deprecated on December 4, 2024. We are considering transitioning to the Instagram Business Login API. However, our application does not include any messaging-related functionality, yet the instagram_business_manage_messages permission appears to be required to publish this product.

Does anyone know whether implementing messaging functionality is mandatory for using the Instagram Business Login API, or is this a mistake? Is it possible to publish the product without the instagram_business_manage_messages scope if the application does not deal with messages?