Get Facebook content using the Facebook PHP SDK

I am trying to get content on facebook ad. Or rather: a link that is part of the ad. I can extract the link from the content, but it seems I cannot get the content in the first place.

After initializing the connection, I get the current account:

$me = new AdUser('me'); /** @var AdAccount $account */ $account = $me->getAdAccounts()->current(); 

I tried with campaigns, ads, and ads, but none of them could contain the actual html content to 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 corresponding fields in campaigns and ads. I looked through all the fields returned by $object->getData() .

+5
source share
1 answer

You must request the correct set of fields with required fields:

 $creatives = $account->getAdCreatives([ AdCreativeFields::NAME, AdCreativeFields::BODY, AdCreativeFields::LINK_DEEP_LINK_URL, AdCreativeFields::LINK_URL, ]); 

Exclusive full list of feeds:

 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'; } 
+2
source

Source: https://habr.com/ru/post/1237754/


All Articles