Posts tagged with facebook-marketing-api

For my Use case, im planning a Live demo where i start an Instagram Marketing Campaign. After launching the Ads, the goal is to present an Instagram Account where the Advertisement can be seen. So it really only needs to be visible on that specific account.

Whats the best way to do this?

  • I saw that there is a sandbox mode, but it states that it doesnt actually launch ads. is that correct?
  • Are the are other test environments i could use?
  • If it has to be the real instagram, is it even possible to narrow the targeting down to a point it could be a guaranteed to show up on that account?

The request I am making is:

[GET] graph.facebook.com/v20.0/[ad_id]/adcreatives?fields=name,url_tags

The Facebook API is bringing me this:

{   "data": [     {       "name": "{{product.name}} XXXX",       "url_tags": "utm_source={{site_source_name}}&utm_medium={{placement}}&utm_campaign={{campaign.name}}&utm_content={{ad.name}}",       "id": "XXXXX"     }   ] } 

I want to translate the url_tags and name fields so that it brings me the real url and name that will be displayed for that creative.

I tried to read the documentation and test all parameters, but I didn't find anything.

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.

I create a webhook that send the lead to our CRM. Everything works fine: I can retrieve the lead, the form and the page data. Now I need to retrieve which business account create the ads for the leads. The ADS are managed by two different agencies and I need to understand each campaign origin.

I think is something that I can retrieve from the form_id but I don't know how. Could someone help me out on this one? Thank you

Using cURL, I am trying to get list of AdSets/Ad Campaigns that are having errors like "creative fatigue" with the help of Facebook Graph API.

I checked Graph API documentation, but couldn't find it. I also tried checking out API Explorer tool, but couldn't find a way to get this information.

Even ChatGPT and other AIs couldn't be of help as the references they give do not work now, current version is 20, but AIs give v13, v16 and so on.

Following are a couple of API endpoints from the many I have tried:

  1. https://graph.facebook.com/v12.0/<adset_id>?fields=id,name,creative{status}&access_token=<access_token>

  2. https://graph.facebook.com/v13.0/act_{ad_account_id}/adsets?fields=name,creative_status

I am expecting an endpoint that will help me fetch all the adsets or adcampaigns which are having the error of "creative fatigue" and other similar errors.