Posts tagged with instagram-api

I am creating a web app which uses Facebook graph apis to allow users connect their Facebook and Instagram account to my app so we could automate content posting on their behalf. I have successfully implementend for Facebook but the problem is now with Instagram. After I initiate the auth url I am taken to a page where I'm asked to enter my IG email and password, a popup opens and I enter those details but it doesn't get past there, it just goes back to telling me to "Get started" which is where I started from.

I have been strugling with this problem for days now and would greatly appreciate any help I could get with this.

Another guess I have: Though I doubt that is the case but could this be happening because I am yet to submit my app for review? If so, why did it work for Facebook?

What I have tried:

  1. I have added and double checked my redirect_uri both on my website and my Facebook developers App
  2. Checked if this issue persists across multiple browsers

What I expect: After entering my instagram username and password, I should be redirected to my redirect_uri with the access_token and other requested information so I can process them

I'm tring to get tagged user in post. Currently I'm fetching user post using Business Discovery and some of the post data is possible to fetch. But for tagged user no information is post.

Is there way or endpoint that I'm just overlooking? or just simply not possible with Business Discovery?

Also if it not possible with Business Discovery I would like to know if there is any other way to do it.

I have my own instagram account and i have created an app in meta for my account automation.

Everytime i automate private replying to a DM, i get below error after sometime.

{   "error": {     "message": "The thread owner has archived or deleted this conversation, or the thread does not exist.",     "type": "IGApiException",     "code": 100,     "error_subcode": 2534001,     "fbtrace_id": "AgLmAH4eepLIf1PqLBN3y4J"   } } 

When i reply with a comment, i get this below error.

{   "error": {     "message": "This API call does not support the requested response format",     "type": "OAuthException",     "code": 20,     "error_subcode": 1772111,     "is_transient": false,     "error_user_title": "Create Comment Failed - Spam Detected",     "error_user_msg": "To protect the Instagram community, your comment was flagged as spam and could not be added. Please review your comment's content and try again.",     "fbtrace_id": "Aj9iw77tVvnd-loKZG7ULPy"   } } 

There is no documentation for these error code on https://developers.facebook.com/docs/messenger-platform/error-codes/

  1. My meta app is verified.
  2. I am using long lived access token in api calls.

Everything seems fine, why is instagram blocking my automation? How is same working with manychat?

Intially i found some reference to verify my app to prevent this error. So, i have verified my meta app with meta.

I'm trying to integrate the Direct Messages webhook for Instagram Graph API but I need more information about the Direct Message, more specifically about a Share. For example, when someone sends a Share to the user, I receive this type of webhook:

"message": {     "mid": "aWdfZAG1f....",     "attachments": [{         "type": "share",         "payload": {             "url": "https://lookaside.fbsbx.com/ig_messaging_cdn/...."         }     }] } 

The payload only has the image URL of the post, nothing else.
I need to know at least the user ID/username of the owner of that post (the user who posted it).
Is there a way I can achieve this?

Thanks in advance!

Hey guys so im trying to automate the post on intagram in my app using the api graph from facebook, i already got the single post of pictures and videos of reels, stories, and post, got as well a carousel of pictures but im having a lot of problem trying to make works to POST a carousel that contais or just reels (videos) and mixed onde having reels and pictures, most of the time i pass the process of creating the container for the first video or picture (when mixed) but in the second one usully or i get a timeout or a erro from graph that dont specify nothing or it fails to create the 2 container and pass the status finished, if anyone can help me would be much appreciated ! my code below !

 function postOnInstagram($fb, $message, $mediaUrls = [], $isCarrosel = false, $pageAccessToken, $instagramAccountId, $hasVideo = false, $typePost){   $fb->setDefaultAccessToken($pageAccessToken);   try {       switch ($typePost) {           case 'post':               if ($hasVideo) {                   return $isCarrosel                        ? postInstagramMediaCarousel($fb, $instagramAccountId, $message, $mediaUrls)                       : postInstagramSingleVideo($fb, $instagramAccountId, $message, $mediaUrls[0]);               } else {                   return $isCarrosel                        ? postInstagramPhotoCarousel($fb, $instagramAccountId, $message, $mediaUrls)                       : postInstagramSinglePhoto($fb, $instagramAccountId, $message, $mediaUrls[0]);               }           case 'reel':               if (!$hasVideo) {                   throw new Exception("Reels require a video");               }               if ($mediaUrls > 1) {                 return postInstagramMultipleVideos($fb, $instagramAccountId, $message, $mediaUrls);               }               else {                 return postInstagramReel($fb, $instagramAccountId, $message, $mediaUrls[0]);               }           case 'story':               if ($hasVideo) {                   return postInstagramStoryVideo($fb, $instagramAccountId, $message, $mediaUrls[0]);               } elseif (!empty($mediaUrls)) {                   return postInstagramStoryPhoto($fb, $instagramAccountId, $message, $mediaUrls[0]);               } else {                   return postInstagramStoryText($fb, $instagramAccountId, $message);               }           default:               throw new Exception("Invalid post type");       }   } catch (FacebookResponseException $e) {       return 'Graph returned an error: ' . $e->getMessage();   } catch (FacebookSDKException $e) {       return 'Facebook SDK returned an error: ' . $e->getMessage();   } catch (Exception $e) {       return 'General error: ' . $e->getMessage();   } } function postInstagramMediaCarousel($fb, $instagramAccountId, $message, $mediaUrls){     $mediaIds = [];     foreach ($mediaUrls as $mediaUrl) {         sleep(10);         // Detect media type based on URL or other means         $mediaType = (preg_match('/\.(mp4)$/i', $mediaUrl)) ? 'VIDEO' : 'IMAGE';         // Create the media and get the creation ID         $creationId = createMediaInsta($fb, $instagramAccountId, $mediaUrl, $mediaType);         if (!$creationId) {             throw new Exception("Failed to create media: $mediaUrl");         }         // Wait for the media to be ready         if (!waitForMediaToBeReadyInsta($fb, $creationId)) {             throw new Exception("Media is not ready: $creationId");         }         $mediaIds[] = $creationId;     }         // Create carousel with the obtained media IDs     $carouselResponse = $fb->post("/$instagramAccountId/media", [         'caption' => $message,         'media_type' => 'CAROUSEL',         'children' => $mediaIds,     ]);       $carouselCreationId = $carouselResponse->getDecodedBody()['id'];     if (!$carouselCreationId) {         throw new Exception("Failed to create carousel.");     }     // Wait for the carousel to be ready     if (!waitForMediaToBeReadyInsta($fb, $carouselCreationId)) {         throw new Exception("Carousel is not ready: $carouselCreationId");     }     sleep(30);     // Publish the carousel     return publishMedia($fb, $instagramAccountId, $carouselCreationId); } function createMediaInsta($fb, $instagramAccountId, $mediaUrl, $mediaType){     // Configura o payload dependendo do tipo de mídia     $payload = [         'media_type' => $mediaType,         'is_carousel_item' => 'true'     ];     if ($mediaType === 'VIDEO') {         $payload['video_url'] = $mediaUrl;     } else {         $payload['image_url'] = $mediaUrl;     }     $response = $fb->post("/$instagramAccountId/media", $payload);     return $response->getDecodedBody()['id']; } function waitForMediaToBeReadyInsta($fb, $creationId, $timeout = 300, $interval = 10){     $start = time();     do {         sleep($interval);         try {             $response = $fb->get("/$creationId");             $status = $response->getDecodedBody()['status'];         } catch (Exception $e) {             // Log the exception and continue waiting             error_log("Exception: " . $e->getMessage());             return false;         }         if ($status === 'READY') {             return true;         }         if (time() - $start > $timeout) {             error_log("Timeout: Media not ready in time.");             return false;         }     } while (true); } function publishMedia($fb, $instagramAccountId, $creationId){   return $fb->post("/$instagramAccountId/media_publish", [       'creation_id' => $creationId   ])->getDecodedBody(); } 

i tried everything that i could find on docs and net but cant find a solution!