Posts tagged with facebook-php-sdk

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.

how can i retrive the billing invoices (payment activities) from my business manager account via PHP SDK of Facebook Business or via Graph API? I would like duplicate the content that i see in page as https://business.facebook.com/billing_hub/payment_activity?asset_id=0000000000&business_id=000000000000&placement=ads_manager&date=00000000_00000000

payment activities on business manager

I have my business account id, my customer adv account id but when i try to retrive che invoices i get the empty response, without any error, but only an empty data. I am sure that the account has many invoices and payment activities.

I have tried both approaches yet

test via API

test via SDK

Facebook page reels video upload with API facing issue

{ "error": { "message": "(#200) subject does not have permission to post videos on this target", "type": "oauthexception", "code": 200, "fbtrace_id": "afayglg374lfu4ml65zprso" } }

Note: upload my own page

Remove Facebook app and reconnect again and allow all permission requirement documentation,

One time everything is perfect but suddenly show this error then I try create new app and try again but still show this problem and also change the my machine(PC) use new Facebook account and new page but You still show this problem