Reputation: 114
I'm trying to get all the comments related to a certain ad account through Facebook Ads API, all I know is the ad_account_id. Is there way to get page_id related to this ad account in order to get the comments on that page?
Upvotes: 2
Views: 812
Reputation: 43816
If you're starting with the ad account ID you need to traverse the graph 'downwards' to the posts which are being promoted and the comments on those posts
For the Ad Account, there are one or more Campaigns, those Campaigns contain one or more Ad Sets, which contain one or more Ads - See the structure in the Overview doc
(A shorter call to get all of the Ads in an account is a call to /<API VERSION>/act_<ACCOUNT ID>/adgroups
)
Once you have the Ads, each Ad has a Creative attached - for most of those Creatives the object being promoted is a Page Post, the ID of which is the object_story_id
parameter of the Ad Creative
Provided you have an access token for the page, or for a user who can see the posts on the page (the page or posts may be restricted demographically), you can then retrieve the details of a post with a call to /<API VERSION>/<POST ID>
and read its comments with a call to /<API VERSION>/<POST ID>/comments
- see the Post or Page Documentation for details
Upvotes: 3