Posts tagged with facebook-graph-api

I face the same problem in Facebook Graph /me missing email.

As the title, I can't get my email by calling facebook graph api 'me?fields=email' now.

Pretty sure that it worked fine before.

I removed my email from my facebook profile and added it to my account again, received an email and confirmed it.

After that I called graph api '/me?fields=email', it didn't return my email, and the developer tool show a debug message "未回傳電子郵件欄位。這可能是因為電子郵件遺失、無效或未經確認。"(In English, it don't return email because the email may be missiong, invalid or not confirmed.)

This is quite weird because I have a confirmed email in my profile, how can I deal with it?

I uploaded a photo via WhatsApp, which can be accessed via:

https://graph.facebook.com/v19.0/{imageId} 

Requesting this API returns the URL of the image:

{     "url": "https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid={imageId}&ext={ext}&hash={hash}",     "mime_type": "image/jpeg",     "sha256": "fd9d5ac5bb84b8a0b7a3402c3a99ed9ff3e9fadb4fa567cd101eaf4923d2b375",     "file_size": 667836,     "id": "{imageId}",     "messaging_product": "whatsapp" } 

Then, accessing this URL by Postman successfully returns the image that I uploaded.

However, when I use Nodejs, it returns something that I cannot convert to an image to be displayed on browsers.

const url = (   await axios.get("https://graph.facebook.com/v19.0/{imageId}", {     headers: {       Authorization: `Bearer ${process.env.WHATSAPP_API_KEY}`,     },   }) ).data.url; const image = Buffer.from(   (     await axios.get(url, {       method: "GET",       headers: {         Authorization: `Bearer ${process.env.WHATSAPP_API_KEY}`,       },     })   ).data ).toString("base64"); console.log(image); // 77+977+977+977+9ABBKRklGAAEBAQBgAGAAAO+... 

This prints some base64-encoded string, but when I test it https://base64.guru/converter/decode/image here, it tells that the string represents an application/octet-stream data. Therefore, I cannot display the image in my Remix code.

<img src={`data:image/jpeg;base64,${image}`} /> // not working 

How can I appropriately retrieve the image as base64 from the API?

I'm encountering an issue with the Facebook Graph API when filtering leads based on the time_created field using UNIX timestamps. It seems that the API's time filtering is not precise down to the second.

For example, if I filter leads created at 06-07-2024 11:58:00 AM (actually in UNIX timestamp) and a lead has a time_created value of 06-07-2024 11:58:12 AM, the lead is still included in the response, resulting in duplicates in my data.

Has anyone else experienced this issue or found a way to ensure the filtering is precise to the second?

My Code:

$currentDateTime = Carbon::now(); //At Very Start of Code. $lastestDate = Carbon::parse(LeadData::latest()->first()->last_processed_time)->getTimestamp(); . . . . $newUrl2 = "https://graph.facebook.com/v20.0/{$adId}/leads"; $paramsNew2 = [     //'since' => $lastestDate,     'filtering' => json_encode([         [             'field' => 'time_created',             'operator' => 'GREATER_THAN', //_OR_EQUAL             'value' => $latestDate, // 1720247400, getting it from DB as last_processed_time.         ]     ]),     'fields' => "id,form_id,platform,partner_name,field_data,ad_id,adset_id,campaign_id,ad_name,adset_name,campaign_name,created_time,post",     'access_token' => $accessToken, ]; $response2 = Http::get($newUrl2, $paramsNew2); $data3 = $response2->json(); $leadDatas = $data3['data'] ?? null; foreach ($leadDatas as $leadData)  {     try      {         LeadData::create([                 'account_id' => $adAccountId ?? null,                 'account_name' => null, ///$accountName,                 'campaign_id' => $leadData['campaign_id'],                 'campaign_name' => $leadData['campaign_name'],                 'adset_id' => $leadData['adset_id'],                 'adset_name' => $leadData['adset_name'],                 'ad_id' => $leadData['ad_id'],                 'ad_name' => $leadData['ad_name'],                 'ad_status' => $adStatus,                 'lead_id' => $leadData['id'],                 'lead_created_time' => $leadData['created_time'],                 'platform' => $leadData['platform'],                 'form_id' => $leadData['form_id'],                 'field_data' => json_encode($leadData['field_data'], JSON_UNESCAPED_UNICODE),                 'last_processed_time' => $currentDateTime,             ]);     } catch (\Exception $e) {         echo "Data entry in database failed: " . $e->getMessage() ."\n";         Log::error($e->getMessage());     } } 

Then I'm saving the leads in the DB.

we are using an app for Facebook Business Manager that allows us to manipulate users' catalogs, enabling us to dynamically add products to their Meta catalog. We are looking to use the "commerce_account_read_settings" permission to determine which of their catalogs is linked to their store. However, this permission does not provide an option for an advanced access request, which means it can be used only by users within this app. Is there a way to submit an advanced access request for this permission so that we can interact with all users and not just those within our business manager?

I do not know where the OAuth error comes from, when I use a wrong ID or access token i get a different error.

curl -i -X POST "https://graph.threads.net/v1.0/user_id_placeholder/threads" -d "media_type=IMAGE" -d "image_url=https://i.postimg.cc/7LLYvNSq/pexels-ozanculha-17858988.jpg" -d "text=#BronzFonz" -d "access_token=placeholder" 
{"error":{"message":"An unexpected error has occurred. Please retry your request later.","type":"OAuthException","is_transient":true,"code":2,"fbtrace_id":"AuXxSa8ftZnjb-aSSAuGr_O"}}