I'm trying to get the content of a facebook ad. Or to be more exact: A link which is part of the ad. I can extract the link from the content, but can't seem to get the content in the first place.
After initializing the connection I get the current ad account:
$me = new AdUser('me');
/** @var AdAccount $account */
$account = $me->getAdAccounts()->current();
I tried with campaigns, ads and creatives, but none of them seam to contain the actual html content of the add.
$campaigns = $account->getCampaigns([
CampaignFields::ID,
CampaignFields::NAME
]);
$ads = $account->getAds([
AdFields::ID,
AdFields::NAME
]);
$creatives = $account->getAdCreatives([
AdCreativeFields::NAME,
AdCreativeFields::BODY
]);
As far as I know, there are no matching fields in campaigns and ads. I looked through all fields returned by $object->getData()
.
You should request a correct fieldset with required fields:
$creatives = $account->getAdCreatives([
AdCreativeFields::NAME,
AdCreativeFields::BODY,
AdCreativeFields::LINK_DEEP_LINK_URL,
AdCreativeFields::LINK_URL,
]);
The currect complete list of fieds is:
class AdCreativeFields extends AbstractEnum {
const ACTOR_ID = 'actor_id';
const ACTOR_IMAGE_HASH = 'actor_image_hash';
const ACTOR_NAME = 'actor_name';
const ADLABELS = 'adlabels';
const APPLINK_TREATMENT = 'applink_treatment';
const BODY = 'body';
const CALL_TO_ACTION_TYPE = 'call_to_action_type';
const DYNAMIC_AD_VOICE = 'dynamic_ad_voice';
const FOLLOW_REDIRECT = 'follow_redirect';
const ID = 'id';
const IMAGE_HASH = 'image_hash';
const IMAGE_FILE = 'image_file';
const IMAGE_URL = 'image_url';
const IMAGE_CROPS = 'image_crops';
const INSTAGRAM_ACTOR_ID = 'instagram_actor_id';
const INSTAGRAM_PERMALINK_URL = 'instagram_permalink_url';
const LINK_DEEP_LINK_URL = 'link_deep_link_url';
const LINK_URL = 'link_url';
const NAME = 'name';
const OBJECT_ID = 'object_id';
const OBJECT_STORY_ID = 'object_story_id';
const OBJECT_STORY_SPEC = 'object_story_spec';
const OBJECT_STORE_URL = 'object_store_url';
const OBJECT_TYPE = 'object_type';
const OBJECT_URL = 'object_url';
const PLACE_PAGE_SET_ID = 'place_page_set_id';
const PREVIEW_URL = 'preview_url';
const PRODUCT_SET_ID = 'product_set_id';
const RUN_STATUS = 'run_status';
const TEMPLATE_URL = 'template_url';
const THUMBNAIL_URL = 'thumbnail_url';
const TITLE = 'title';
const URL_TAGS = 'url_tags';
const VIDEO_ID = 'video_id';
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With