简体   繁体   中英

facebook api marketing create campaign issue

I would like to create a campaign using Facebook API. I tried to run all available example without success.

First of all I created an App in order to have a APP_ID and a APP_SECRET.

I did all the procedure to add my Ad_account following the tutorial.

I downloaded all the SDK to facilitate Facebook API use like:

  1. facebook-php-ads-sdk and run adgroup_creation.php and curl_log.php with my data, without success.

  2. facebook-php-sdk-v4 I suppose it is less specific than the previous one.

  3. Multi-Product Ads with the Facebook Marketing POST -> developers.facebook.com/ads/blog/post/2015/03/26/creating-multi-product-ads/

  4. the developers reference -> developers.facebook.com/docs/reference/php/4.0.0

I used "Composer" to get all dependency.

In all this case I had problem to create a campaign using more or less this code:

$campaign = new \FacebookAds\Object\AdCampaign(null,"act_$ACCOUNT_ID");

$campaign->setData(array(
AdCampaignFields::NAME => 'My First Campaign',
AdCampaignFields::OBJECTIVE => AdObjectives::WEBSITE_CLICKS,
AdCampaignFields::STATUS => AdCampaign::STATUS_PAUSED ));

// PROBLEM is Here 
$campaign->create();

Any help? How can I get a more useful error?

It's difficult to help without knowing the exact error. However, you could try this: before creating your campaign, initialize the API using:

Api::init(<your_app_id>, <your_ap_secret>, <your_token>);

(You need to load FacebookAds\\Api to use this function).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM