How to get Facebook ad permalink using Facebook APi
Asked Answered
B

1

5

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

Borrowing answered 31/8, 2016 at 21:41 Comment(1)
Also wondering this. I noticed for some types of pages you can do https://facebook.com/{page_id}/posts/{post_id} but that doesn't seem to work for community pages.Bibber
P
7

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.

Poulson answered 4/11, 2016 at 13:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.