Facebook:如何从URL获取对象ID

6
我正在尝试实现Facebook评论API(如果您有时间,请参见this问题),我需要获取一个对象ID,而我所拥有的只是对象URL。如果我使用Facebook debug,他们会给我这样的东西: Graph API: http://graph.facebook.com/451006711598242 我相信451006711598242是我的ID。我一直在尝试进行以下调用: https://graph.facebook.com/comments?id={myUrl}但它不起作用。有什么想法我需要做什么?
1个回答

0

尝试使用以下代码返回 object_id:

$object_url = 'http://google.com';
$url = 'SELECT url, id, type, site FROM object_url WHERE url = "'.$object_url.'"';
$fql_query_url = 'https://graph.facebook.com/fql?q='.urlencode($url);
$fql_query_result = file_get_contents($fql_query_url);
$fql_query_obj = json_decode($fql_query_result, true);  

$object_id = $fql_query_obj['data'][0]['id'];

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接