mingfish_004
mingfish_004

Reputation: 1413

how to know the post id base on url given?

I want to use facebook php api to post a comment,
but I only know the page url, no post id,
how to know the post id base on url given?

$post_data=array(
    'message'=>'post a comment test',
    'link'=>'http://www.persunmall.com/p19000', // how to know post id
);


// how can i know the post id base on the link?
$facebook->api('/'.$post_id.'/comments','post',$post);

Upvotes: 0

Views: 125

Answers (1)

LoganEtherton
LoganEtherton

Reputation: 495

The post ID can be found in the array returned from the call to $facebook->api.

For example:

$facebook->api(<your API call>);

Then you can find the post ID in $result['id'] when making a call to 'feed', as demonstrated here

$result = $facebook->api('/121468571287906/feed/','post',$attachment); 

Additionally, Facebook's API returns a response object, which will contain a post ID for the original call. Try adding a return value to your original call, and then examining that. For example, examine the details of $returnObject for this code:

$returnObject = $facebook->api('/'.$post_id.'/comments','post',$post);

Please refer to the Facebook API reference for details.

Upvotes: 1

Related Questions