// use FacebookAds\Object\Fields\AdImageFields; // use FacebookAds\Object\Fields\AdGroupFields; // First, upload the ad image that you will use in your ad creative // Please refer to Ad Image Create for details. // Then, use the image hash returned from above $creative = new AdCreative(null, $ad_account_id); $creative->setData(array(AdCreativeFields::TITLE => 'My Test Creative', AdCreativeFields::BODY => 'My Test Ad Creative Body', AdCreativeFields::OBJECT_URL => 'https://www.facebook.com/facebook', AdCreativeFields::IMAGE_HASH => $image_hash)); // Finally, create your ad along with ad creative. // Please note that the ad creative is not created independently, rather its // data structure is appended to the ad group $adgroup = new AdGroup(null, $ad_account_id); $adgroup->setData(array(AdGroupFields::NAME => 'My Ad', AdGroupFields::CAMPAIGN_ID => $ad_set_id, AdGroupFields::CREATIVE => $creative, AdGroupFields::ADGROUP_STATUS => AdGroup::STATUS_PAUSED)); $adgroup->create(); // _DOC close [ADGROUP_CREATE_INLINE_CREATIVE] // fetch the id of the generated creative $adgroup->read(array(AdGroupFields::CREATIVE)); $creative->{AdCreativeFields::ID} = $adgroup->{AdGroupFields::CREATIVE}['id']; // _DOC open [ADGROUP_GET_TARGETING_DESCRIPTION] // _DOC vars [ad_group_id] // use FacebookAds\Object\AdGroup; $adgroup = new AdGroup($ad_group_id); $targeting_description = $adgroup->getTargetingDescription(); // Output targeting description foreach ($targeting_description->targetingsentencelines as $description) { echo $description['content'] . PHP_EOL; foreach ($description['children'] as $child) { echo "\t" . $child . PHP_EOL; } } // _DOC close [ADGROUP_GET_TARGETING_DESCRIPTION] $adgroup->delete();