Posts tagged with instagram

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?

I'm experiencing an issue with Instagram Direct referral data being passed through the webhook. In some cases, when a user clicks a "Click to Instagram Direct" ad, the webhook includes referral information (e.g., "source": "ADS", "ad_id", etc.). However, for other users who click the very same ad, the webhook payload contains no referral object at all-only the basic message fields. In Meta Business Suite (Ads Manager), I can see that both groups of users did indeed come from the ad. Yet only some of them generate referral data in the webhook. Here are two JSON examples showing the difference: With referral data (includes "referral": { "source": "ADS", "ad_id": Without referral data (no referral field, despite the user coming from the same Instagram ad). have already verified that: My webhook is subscribed to messaging_referrals. The ads are set up using the "Click to IG Direct" objective/format. Everything else in my setup seems consistent. I would be glad to hear any advice on what the problem may be, or if there are any nuances in using Facebook

UPD: I have managed to reproduce this problem, namely if I go to an advertisement in the news feed, click ‘send message’, a modal window appears, after which I do not respond to the message, but close it and go to my account, after which I respond to the welcome message from the advertisement. In this case, we receive a text message via webhook. My pages are subscribed to messages,feed,messaging_postbacks,messaging_referrals

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

am working with the Instagram Graph API to retrieve Instagram followers count for accounts linked to Facebook Pages. I am using the following scopes: instagram_basic and pages_show_list.

While the API works for some Facebook accounts and returns the Instagram followers count correctly, it does not work for other accounts, even though those accounts have Instagram Business or Creator accounts linked to their Facebook Pages.

Here’s an outline of my setup:

I use the endpoint GET /{page_id}?fields=instagram_business_account to fetch the Instagram Business Account ID. Once I have the Instagram Business Account ID, I query GET /{instagram_account_id}?fields=followers_count to get the followers count. For some Facebook Pages, the instagram_business_account field is returned as null, even though the Instagram accounts are properly linked to the Facebook Pages.

I have ensured:

The access token has the required permissions (instagram_basic, pages_show_list). The user token is generated correctly, and the app is authorized for all required permissions. The Instagram accounts in question are Business or Creator accounts and linked correctly to the Facebook Pages.

Has anyone faced a similar issue? Are there additional permissions or configurations needed to consistently fetch the Instagram Business Account ID and followers count?

Any guidance or insights would be appreciated!

Thank you.

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.