Posts tagged with instagram-graph-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?

In my meta application with instagram api with instagram login when I define the "Data deletion request URL" the POST request send to my route with following body content

POST /api/delete HTTP/1.1 Host: 26d5-45-8-19-76.ngrok-free.app User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1) Content-Length: 166 Accept: */* Accept-Encoding: deflate, gzip Content-Type: application/x-www-form-urlencoded X-Forwarded-For: 2a03:2880:30ff:8:: X-Forwarded-Host: 26d5-45-8-19-76.ngrok-free.app X-Forwarded-Proto: https signed_request=NybldKYslIBJJfCjH9jIE6PI3ohOKimGpB293v1ojeI.eyJ1c2VyX2lk....... 

I can't verify the content using header provided based on the description that provided in following link Data Deletion Request Callback

I did following in the NestJS framwork service

import { Injectable } from '@nestjs/common'; import * as crypto from 'crypto'; @Injectable() export class SignedRequestService {   private readonly secret = 'appsecret'; // Use your app secret here   parseSignedRequest(signedRequest: string): any | null {     const [encodedSig, payload] = signedRequest.split('.', 2);     // decode the data     const sig = this.base64UrlDecode(encodedSig);     const data = JSON.parse(this.base64UrlDecode(payload));     // confirm the signature     const expectedSig = crypto       .createHmac('sha256', this.secret)       .update(payload)       .digest();     if (Buffer.compare(Buffer.from(sig), expectedSig) !== 0) {       console.error('Bad Signed JSON signature!');       return null;     }     return data;   }   private base64UrlDecode(input: string): string {     const base64 = input.replace(/-/g, '+').replace(/_/g, '/');     return Buffer.from(base64, 'base64').toString('utf-8');   } } 

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