facebook / facebook-php-business-sdk

PHP SDK for Meta Marketing API
https://developers.facebook.com/docs/business-sdk
Other
818 stars 514 forks source link

Ad Must Be Associated With a Facebook Page #453

Closed palpalani closed 5 years ago

palpalani commented 6 years ago

I am trying to create an ad using sample code provided by Facebook: https://raw.githubusercontent.com/facebook/facebook-php-business-sdk/6792f3c636875af0c5bef921d17729af30b1c15a/examples/adgroup_creation.php

Up to 5 steps are working, but 6 th step adCreavive not working. It always gives the error "Ad Must Be Associated With a Facebook Page".

If I set AdCreativeFields::OBJECT_ID it gives a different error.

--0--

I try with another sample code provided here: https://developers.facebook.com/docs/marketing-api/buying-api for creating adCreative.

This gives an error saying that my App is in development mode. Since I just created my app and it not submitted for review.

Someone help me to proceed next.

effetb commented 6 years ago

Hi, same issue here.

The examples are completly broken and I just can't find how to create an ad properly... What a waste of time. Can you please update the examples to match the new code ?? I use the v3.0 branch

palpalani commented 6 years ago

Now, I am able to create ads.

Using this document: https://developers.facebook.com/docs/marketing-api/buying-api and now API asking to Instagram account, for that, I use this help: https://stackoverflow.com/a/44054867

effetb commented 6 years ago

Thank you ! I managed to publish ads but I wasn't able to save the ad creative. It seems that the only difference was in the ad creation, i was using the creative object


$ad_id = null;

$ad = new Ad($ad_id);
$ad->setParentId($account_id);
$ad->setData(array(
    AdFields::NAME     => 'My Ad',
    AdFields::ADSET_ID => $adset_id,
    AdFields::CREATIVE => $creative,
    AdFields::STATUS   => \FacebookAds\Object\Values\AdStatusValues::PAUSED
));

instead of that

    AdFields::CREATIVE => array('creative_id' => $creative_id),

And thank you for the instagram account, i had also the error.

jingping2015 commented 5 years ago

Please take look the example here https://developers.facebook.com/docs/marketing-api/reference/adgroup/