Reputation: 11
With Facebook Ad Api, I can't create ad(group) although I have created the Campaign, AdSet, and AdCreative. I have followed instruction of facbook guide(with the all required parameters). I can't find the answer by any googling.... What's wrong? (I just found the change that ADGROUP_STATUS is required now.)
------------ PHP Codes ------------------
use FacebookAds\Object\AdGroup;
use FacebookAds\Object\Fields\AdGroupFields;
$adgroup = new AdGroup(null, $account->id);
$adgroup->setData(array(
AdGroupFields::CREATIVE => array('creative_id' => $creative->id),
AdGroupFields::NAME => 'My First AdGroup',
AdGroupFields::CAMPAIGN_ID => $adset->id,
AdGroupFields::ADGROUP_STATUS => 'ACTIVE',
));
$adgroup->create();
Upvotes: 1
Views: 498
Reputation: 552
If you use the following curl code, Facebook's error messages on curl are more descriptive. It's a shame failure messages of this nature don't carry through to the php ads api. Instead you just get "Invalid Parameter"
curl -X POST -F "name=My Ad" -F "campaign_id=<ADSET_ID>" -F "creative={'creative_id': <CREATIVE_ID>}" -F "adgroup_status=<STATUS>" -F "access_token=<ACCESS_TOKEN>" "https://graph.facebook.com/v2.2/act_<ad account id>/adgroups
You will probably get this message.
{"error":{"message":"Invalid parameter","type":"FacebookApiException","code":100,"error_data":{"blame_field_specs":[["account_id"]]},"error_subcode":1359101,"is_transient":false,"error_user_title":"Add Payment Method","error_user_msg":"You need to have a valid payment method associated with your ad account before you can create ads."}}
Which means since you were developing for this and probably using a test app with your user id you didn't realize that Facebook still requires you to have a valid payment method for ads in order to even create a paused ad with a test app.
I would recommend that you start with paused ads as you probably don't want to be billed for it while testing.
I guess the argument could me made (why require live payment credentials in order to create even a paused app} but also you could argue that the test isn't valid unless all requirements are met.
Hope this helps. This was my problem
Upvotes: 1