Posts tagged with facebook-graph-api

I'm experiencing an intermittent issue when calling Facebook Graph API endpoints from my server and localhost using the Node Facebook SDK. The error message I receive is:

Error:

Message: "An unknown error has occurred." Code: 1

There's any more useful information in the error nor in the response headers.

This error happens sporadically and, when it occurs, it can last for several hours or even days. I’m unable to reproduce it consistently.

**Interestingly, when I make the same API calls through Postman or the Graph API Explorer, everything works fine without any errors. ** Has anyone encountered this issue before or have insights on why this might be happening? Any suggestions on how to troubleshoot or resolve this would be greatly appreciated!

Thank you!

I inspected the facebook error response searching for any more information about the error, but there's any


This happens to me with different requests. See an example:

https://graph.facebook.com/v20.0/campaign-id-example/adsets?fields=optimization_goal%2Cpromoted_object&access_token=xxxx

hello guys im trying to automate a stories video post on facebook but dont know what im doing wrong, my picture stories function works fine but my video one is not working at all!!! i tried to look over here and documentation for a answer but couldnt find a solution! in the first 10 calls i was getting errors from graph and from now on i keep getting erro 500! does anyone knows what i can be doing wrong?

    function postStoriesVideoFacebook($fb, $pageId, $pageAccessToken, $mediaUrls){         $mediaUrls = 'https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4';        // Etapa 1: Inicializar a sessão de upload        $response = $fb->post("/{$pageId}/video_stories", [         'upload_phase' => 'start',     ], $pageAccessToken);     $initData = $response->getDecodedBody();     $videoId = $initData['video_id'];     $uploadUrl = $initData['upload_url'];     // Debugging - Verificando as variáveis     var_dump($initData, $videoId, $uploadUrl);     // Etapa 2: Fazer upload do vídeo usando a URL remota     $ch = curl_init();     curl_setopt($ch, CURLOPT_URL, $uploadUrl);     curl_setopt($ch, CURLOPT_POST, true);     curl_setopt($ch, CURLOPT_HTTPHEADER, [         "Authorization: OAuth $pageAccessToken", // Passando o token como OAuth         "file_url: $mediaUrls"     ]);     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);     $uploadResponse = curl_exec($ch);     curl_close($ch);     $uploadData = json_decode($uploadResponse, true);     // Debugging - Verificando a resposta do upload     var_dump($uploadData);     if (isset($uploadData['success']) && $uploadData['success'] === true) {         // Etapa 3: Publicar o vídeo nos Stories         $finishResponse = $fb->post("/{$pageId}/video_stories", [             'upload_phase' => 'finish',             'video_id' => $videoId,         ], $pageAccessToken);         $result = $finishResponse->getDecodedBody();         // Debugging - Verificando a resposta da publicação         var_dump($result);         if (isset($result['success']) && $result['success'] === true) {             return $result['post_id']; // Retorna o ID do post se a publicação for bem-sucedida         } else {             throw new Exception('Erro ao publicar o vídeo nos Stories.');         }     } else {         throw new Exception('Erro ao fazer upload do vídeo.');     } } 

forums , using direct the cURL options, postman etc

I'm developing an application to capture leads from a Facebook lead form. Here's what I've done so far:

  1. I created an App in the Facebook Developer Dashboard.
  2. I verified the webhook for this app, and the verification was successful.
  3. I have obtained advanced access for the following permissions: leads_retrieval, pages_show_list, pages_manage_metadata.
  4. I have enabled the User object and subscribed to leadgen events.
  5. I tested the webhook, and it's sending test leads in the response as expected.
  6. My app is in Live mode.

However, when a real lead is created on Facebook, I'm receiving the following response instead of the actual lead data:

{   "entry": [     {       "id": "0",       "time": 1724921046,       "changes": [         {           "field": "leadgen",           "value": {             "ad_id": "444444444",             "form_id": "444444444444",             "leadgen_id": "444444444444",             "created_time": 1724921046,             "page_id": "444444444444",             "adgroup_id": "44444444444"           }         }       ]     }   ],   "object": "page" } 

What could I be doing wrong, and how can I start receiving real lead data instead of this mock response?

this is screen shot of my app:- App details:- Permission Details:- Webhook Details:-

Here are the steps I took to get access_token

// Init FB SDK const loadSdk = () => {     window.fbAsyncInit = function () {         window.FB.init({             appId: "218446344509498",             cookie: true,             xfbml: true,             version: "v19.0",         });     };     if (!document.getElementById("facebook-jssdk")) {         const js = document.createElement("script");         js.id = "facebook-jssdk";         js.src = `https://connect.facebook.net/en_US/sdk.js`;         document.body.appendChild(js);     } }; loadSdk(); 

Then I opened the popup that I need for whatsapp embedded sign up

window.FB.login((response) => {     if (response.authResponse) {         const code = response?.authResponse?.code;         console.log(code)     } }, {     config_id: <config-id>, // configuration ID goes here     response_type: "code",     override_default_response_type: true,     scope: 'business_management, whatsapp_business_management, whatsapp_business_messaging', }) 

When I code the code I retrieved my access_token on the server side using the following API

https://graph.facebook.com/v20.0/oauth/access_token?client_id=<client-id>&client_secret=<client-secret&code=<code-i-previously-retrived> 

This returns me an access token that seems to be working with Meta APIs /me, //owned_whatsapp_business_accounts But it returns empty arrays or objects.

When I do the same thing from Meta explorer (select permissions, generate token, copy that token and use, it works)

I have been trying to solve this since many days and not sure where I am doing the mistake.

I want to generate token with correct permissions (it looks like I am doing it because authentication popup also mentions the permissions I requested), and want to able to fetch information from it not empty array

We can see the Delivery field on Facebook's ad placement interface to determine whether the ad is in Active, Learning limited, or Learning status. How can we use the official API to retrieve this field?

I have read the corresponding official documentation. but I couldn't find the corresponding field in it. https://developers.facebook.com/docs/marketing-api/reference/adgroup#overview