How to get Facebook ad permalink using Facebook APi

本秂侑毒 提交于 2019-12-06 05:14:56

问题


When using ads manager, you can preview ad. There is also a hyperlink which goes View post permalink with comments. Is there any way to get that link using API


回答1:


First you must get the creative that's targeted by the ad.

$ad = new Ad($ad_id);
$ad->read(array(
    AdFields::CREATIVE,
));

Then get the info from the creative.

$creative = new AdCreative($ad->creative['id']);
$creative->read(array(
    AdCreativeFields::EFFECTIVE_OBJECT_STORY_ID,
));

Then $creative->effective_object_story_id will contain an ID that would look like xxxxxxxxxxxxx_yyyyyyyyyyyyy, where x is the ID of the page, and y is the id of the post/video/etc. If you just go to https://facebook.com/xxxxxxxxxxxxx_yyyyyyyyyyyyy it should redirect you to the correct post

Hope this helps someone.



来源:https://stackoverflow.com/questions/39259459/how-to-get-facebook-ad-permalink-using-facebook-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!