dongmanni6916
2018-11-19 11:27
浏览 577
已采纳

Facebook API(PHP):获取完整的广告列表

I am using Facebook API to fetch the full Ads list.

The Code is working, But it return only 25 Ad in case of i have 150+ Ad in my account.

I guess that happens because of the query limits on the Facebook API.

My Code:

$account = new AdAccount('act_<AD_ACCOUNT_ID>');
$account->read();

$fields_adset = array(
  AdSetFields::ID,
  AdSetFields::NAME,
  AdSetFields::CAMPAIGN_ID,
  AdSetFields::STATUS,
);

$ads = $account->getAds($fields_adset);

foreach ($ads as $adset) {
    $adset_id = $adset->{AdSetFields::ID};
    echo  $adset_id;
    //print_r($adset);
    //exit();
}

So, they mentioned in the documentation that :

Use Asynchronous Requests to query a huge amount of data

Reference (1) : https://developers.facebook.com/docs/marketing-api/best-practices/

Reference (2) : https://developers.facebook.com/docs/marketing-api/insights/best-practices/#asynchronous

But, I can't apply that "Asynchronous" requests to my code to fetch the Full Ad List,

Please help me to fetch the full Ads list

Thank you.

1条回答 默认 最新

相关推荐 更多相似问题