2
votes

I am building a PHP script based on Facebook Marketing API,

The API system works fine,

I can get the result for the campaigns, the ads, and full insights as well.

But, I want to get the result of the leads.

Note (1): I got admin access to the APP, the Ad account, and the page as well,

Note (2): App Status: In Development

Note (3) : I send the API request for "leads_retrieval" and "leads_retrieval",

$permissions = ['email','public_profile','leads_retrieval','ads_management', 'ads_read', 'business_management', 'read_audience_network_insights', 'read_insights', 'manage_pages', 'pages_show_list', 'pages_manage_cta','pages_manage_instant_articles', 'publish_pages', 'read_page_mailboxes'];

My Code to get the lead result :

$ad = new Ad('<AD_ID>');
$leads = $ad->getLeads();
$lead = $leads->getResponse()->getBody();

print_r($lead);

Result:

{"data":[]}

So for some reason, I still get the incorrect empty result for the leads!

Any idea about how to get the correct lead result for the Ad?

Reference : https://developers.facebook.com/docs/marketing-api/guides/lead-ads/retrieving/v2.9

1
You could try to inspect with the debug token utility if the token have the proper permisionMatteo
@Matteo : could you please write a full reply with a code sample for the debug token in this case ?m500500
hi! You can try to debug the Access Token using the Access Token Debugger Only for double check the token have the proper permission (This is not a real answer so I post as comment)Matteo

1 Answers

-1
votes

I have same problem before but I found that I'm using incorrect ad_id.

double check you ad id, its possible that your not getting the full list of ad id inside adset.

use $ads->fetchAfter() to get the next page of ads

check complete code here https://stackoverflow.com/a/56500241/2588592