Reputation: 33
an advanced thank you for taking time answering this. I would like to retrieve all of my campaign list in facebook marketing API.
this is my code:
use FacebookAds\Object\AdUser;
use FacebookAds\Object\AdAccount;
use FacebookAds\Object\Fields\AdAccountFields;
use FacebookAds\Object\Campaign;
use FacebookAds\Object\AdCampaign;
use FacebookAds\Object\Fields\CampaignFields;
use FacebookAds\Object\Fields\AdCampaignFields;
use FacebookAds\Object\Fields\AdsInsightsFields;
use FacebookAds\Object\Fields\AdSetFields;
$account = new AdAccount($account_id);
$params = array(
'time_interval' => array(
'day_start' => array('year' =>'2015', 'month'=> '5', 'day'=>'1'),
'day_stop' => array( 'year'=>'2015', 'month'=>'5', 'day'=>'31')
),
'limit' => 500,
);
$fields = array(
AdCampaignFields::NAME, /* <--- this is the error */
AdCampaignFields::OBJECTIVE,
AdCampaignFields::STATUS,
);
$campaigns = $account->getAdCampaigns($fields,$params);
print_r($campaigns);
Now there are no result shown instead there's an error:
[14-Feb-2017 01:26:55 UTC] PHP Fatal error: Class 'FacebookAds\Object\Fields\AdCampaignFields' not found in /home/rbadmin17/public_html/test_17/index.php on line 98
I already call the "AdCampaignFields" and still it says Class not found.
Thanks for the help...
Upvotes: 2
Views: 771
Reputation: 717
Your code looks correct but the class AdCampaignFields doesn't yet exist in the up to date SDK and was replaced by CampaignFields class (which isn't actually needed for your code).
Your code should work just by removing the line :
use FacebookAds\Object\Fields\AdCampaignFields;
Edit: in fact some examples of the FB doc are deprecated. Just take a look in the SDK folders to see by yourself when you get this kind of error. Sometimes it's just a class name which have been changed.
Upvotes: 1