
通过Graph API Explorer(https://developers.facebook.com/tools/explorer)可直观地测试Graph API的一些功能,在“Get Token”下拉框中点击”Get Access Token”可授权API获取不同的数据
对一些公开数据可直接通过url访问获取,如https://graph.facebook.com/cocacola, 也可以选择通过php的curl可以直接在代码获取到相关信息,php演示代码如下:
$graph_url= "https://graph.facebook.com/cocacola";
// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, $graph_url);
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = curl_exec($ch);
// close curl resource to free up system resources
curl_close($ch);
$arr = json_decode($output);
echo '<pre>';
var_dump($arr);
echo '</pre>';
//echo $arr->id;
点击此处查看执行效果