Posts tagged with facebook-graph-api

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!

There is no API reference for swift in Supabase for sign in a user through facebook. is there any other method for swift which i can use for facebook auth?

I have used this snippet to use google provider to authorize user in supabase...

client.auth.signInWithIdToken(credentials: OpenIDConnectCredentials(                     provider: provider,                     idToken: idToken,                     accessToken: accessToken                 )) 

I am getting this error when click on Send Message In API setup section (Sending of message failed. There was a problem with the access token or permissions you are using for the API call) [First Issue]

Its working perfect few hours ago facing problem after creating a new Facebook business profile in same Facebook profile and verified it and other thing i do is add a new number in meta business suite, and in my other business profile i unable to add phone number for onboarding.

getting this error in second profile

There was a problem registering your phone number This page is not available right now. Please try reloading in a few minutes. (Second Issue)

is there anybody who face this problem or have any solution for this.

My website uses FacebookClient to get the company's Facebook feed and display the latest posts on the site. It's no longer working (not sure how long ago it stopped). The access token expired a while ago, so I updated the access token, and the access token now works (I don't get an exception now on dynamic feedData = (IDictionary<string, object>)client.Get($"{pageId}/feed", new Dictionary<string, object> { { "limit", numResults } }); but it just returns an empty array.

I know that the pageId and accessToken are valid, because this code works:

dynamic coverImage = client.Get(pageId, new Dictionary<string, object> {     { "fields","picture" } }); 

but the call to get the feed returns no posts.

To make testing easier, I'm testing in https://developers.facebook.com/tools/explorer?method=GET&path={pageId}%2Ffeed&version=v20.0. I get the same results in the explorer. No error, just an empty data array:

{   "data": [   ] } 

I verified there are posts on the Facebook page as recent as 4 hours ago. If the access token and pageId are valid, why is {pageId}/feed returing no data?