Facebook:如何从网址获取对象ID

问题描述:

我正在尝试实施Facebook评论api(如果有问题,请参见问题您有时间),我需要获取一个对象ID,而我所拥有的只是对象URL.如果我要使用Facebook调试,他们会给我一些类似的信息: 图形API: http://graph.facebook.com/451006711598242

I am trying to Implement Facebook comments api(See this question if you got time), I need to get an Object id, all what I have is Object URL. If I will use Facebook debug, they are giving me some thing like this: Graph API: http://graph.facebook.com/451006711598242

我相信451006711598242是我的ID.我一直在尝试进行休闲活动: > https://graph.facebook.com/comments?id= {myUrl},但这是不工作.有什么需要做的主意吗?

I believe that 451006711598242 is my id. I been trying to do the fallow calls: https://graph.facebook.com/comments?id={myUrl} but it's not working. Any ideas what I need to do?

尝试使用此方法返回object_id:

Try this to return the 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'];