Posts tagged with instagram-graph-api

I'm encountering an issue with retrieving Instagram posts using the Facebook Graph API. When I use recent timestamps within a month, the following code works fine:

graph.facebook.com/v19.0/{instagram_business_account}?fields=business_discovery.username({ig_user_id}){media.since(1704477217).until(1714477219){timestamp,caption}}&access_token={access_token}

However, when I attempt to use older timestamps, even though the time interval (difference between since and until) remains the same, the request doesn't return the expected results.

For instance:

graph.facebook.com/v19.0/{instagram_business_account}?fields=business_discovery.username({ig_user_id}){media.since(1672834201).until(1672835201){timestamp,caption}}&access_token={access_token}

Despite being certain that there's a specific post at that interval of time, the API doesn't seem to return it.

I am trying to send messages using Graph API where I have certain permissions

email, pages_show_list, business_management, pages_messaging, pages_messaging_subscriptions, instagram_basic, instagram_manage_comments,instagram_manage_insights, instagram_content_publish,, instagram_manage_messages, pages_read_engagement, pages_manage_metadata, pages_read_user_content

Now the wierd part is I have two Roles(Admin both of them, both of them has a Facebook page and connected business instagram account) in the app, Now for one user I am able to send message while in other i get a 403 error

error Data: {   error: {     message: '(#200) Please check if access token has enough IG permissions granular scopes for IG to send API, or if IGSID is valid.',     type: 'OAuthException',     code: 200,     error_subcode: 2534067,     fbtrace_id: 'AouX27HuHoQBu65bb6rBUal'   } } Error Status: 403 Error Headers: AxiosHeaders {   vary: 'Origin',   'access-control-allow-origin': '*',   'cross-origin-resource-policy': 'cross-origin',   'x-app-usage': '{"call_count":5,"total_cputime":0,"total_time":3}',   'content-type': 'application/json',   'www-authenticate': 'OAuth "Facebook Platform" "insufficient_scope" "(#200) Please check if access token has enough IG permissions granular scopes for IG to send API, or if IGSID is valid."',   'facebook-api-version': 'v19.0',   'strict-transport-security': 'max-age=15552000; preload',   pragma: 'no-cache',   'cache-control': 'no-store',   expires: 'Sat, 01 Jan 2000 00:00:00 GMT',   'x-fb-request-id': 'AouX27HuHoQBu65bb6rBUal',   'x-fb-trace-id': 'ERIKbq1Rjf7',   'x-fb-rev': '1012935256',   'x-fb-debug': 'mVMrRrBF3H+nrrHR45BNeWtyqALnup35FrQb9RD8JNQCpmH3n8NhTPYqWVns6Snt1oY6x7RCHIvGzO1cJLP9UQ==',   date: 'Sat, 20 Apr 2024 18:38:20 GMT',   'proxy-status': 'http_request_error;   ......... <some other headers> 'x-fb-connection-quality': 'EXCELLENT; q=0.9, rtt=5, rtx=0, c=10, mss=1380, tbw=372, tp=-1, tpl=-1, uplat=514, ullat=0',   'alt-svc': 'h3=":443"; ma=86400',   connection: 'close',   'content-length': '241' } 

Can anyone please tell me what is going wrong. I tried to create another app, and didn't add user1(for which messages were working) added only user2 and tried sending messages, it was not working. But as soon as I added user1 to this new app, again i was able to send message through this User1's page access token.

Expecting it to work. but it didn't

I am trying to get a long-lived access token from the Instagram graph API through a python script. No matter what I do, I keep receiving the following error:

{"error":{"message":"Missing client_id parameter.","type":"OAuthException","code":101,"fbtrace_id":"AogeGpzZGW9AwqCYKHlmKM"}} 

My script is the following:

import requests refresh_token_url = 'https://graph.facebook.com/v19.0/oauth/access_token' payload = {     'grant_type': 'fb_exchange_token',      'client_id': '1234567890123456'     'client_secret': '1234abcd1234abcd1234abcd',         'fb_exchange_token':'abcd1234' } r = requests.get(refresh_token_url, data=payload) 

I am for sure passing the client_id parameter. I verified also by printing r.request.body

On the contrary, the request is successful if I send it with the Postman app:

Why do I keep getting that error message? Thank you!

I've been able to success connect to Facebook Graph API for Instagram and now I have all messages and conversations stored and I also can send messages to any user I want, but, I'm trying to find two endpoints that seems impossible to:

  1. An endpoint or param to REPLY to a specific direct message, not just send a message to the user.
  2. An endpoint or param to mark a conversation as read, because besides I'm sending DMs via API, in the app the conversation still marked as unread.

Anyone have any idea?

Thanks!

I've tried to use Facebook endpoints but didn't worked, I also tried to copy Whatsapp but again it failed.

Currently in the developing stages of a web app that will allow users to connect their Instagram & Facebook via OAuth then enable an automation that will send new IG posts to their Facebook.

Is there an IG Graph Webhook available for this? Or will I need to set up an API call from my app to watch for the new posts.

I also have an app created & verified with Meta already as a business app. I'm wondering if this was the right decision to create it as a business or should it be a consumer app.

When subscribing to a webhook, I was not able to locate anything to subscribe to 'new posts'.

If the next option is to set up an API call to watch for new posts for every 'x' amount of minutes is there an endpoint and headers that is provided in the docs to set this up?

Any other avenues on how to successfully get this feature up would be greatly appreciated!