Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Facebook API如何获取用户页面_Facebook_Api - Fatal编程技术网

Facebook API如何获取用户页面

Facebook API如何获取用户页面,facebook,api,Facebook,Api,我使用以下代码为Facebook用户获取信息 有没有办法获取用户页面(如果用户有一个或多个Facebook页面)和这些页面的ID $user = $_POST['uid']; //the returned user ID from Facebook $key = $_POST['usid']; //the returned session ID from Facebook $accesstoken = $_POST['accesstoken']; //the returned accessto

我使用以下代码为Facebook用户获取信息

有没有办法获取用户页面(如果用户有一个或多个Facebook页面)和这些页面的ID

$user = $_POST['uid']; //the returned user ID from Facebook
$key  = $_POST['usid']; //the returned session ID from Facebook
$accesstoken = $_POST['accesstoken']; //the returned accesstoken from Facebook
$image = "http://graph.facebook.com/" .$user ."/picture?type=large"; //Facebook Profile Picture
$name = json_decode(file_get_contents('https://graph.facebook.com/' . $user))->name; //Name of the user account on Facebook
$link = json_decode(file_get_contents('https://graph.facebook.com/' . $user))->link; //Link of the user profile on Facebook
$gender = json_decode(file_get_contents('https://graph.facebook.com/' . $user))->gender; //Gender of the user on Facebook
$locale = json_decode(file_get_contents('https://graph.facebook.com/' . $user))->locale; //Location of the user on Facebook
$url = "https://graph.facebook.com/". $user ."/feed?limit=1&access_token=".$accesstoken; //We get the latest status update on the Facebook Wall
$json = file_get_contents($url);
$jsonData = json_decode($json);
foreach($jsonData->data as $val) {
if($val->from->id == $user) {
$statusmessage = $val->message; //Finally we got the latest status update if there is one on The Facebook Wall
break;
}
}

如果你问如何根据一个用户的Facebook Id获得更多的用户资料,答案是你不能。Facebook要求每个用户拥有一个个人资料。在现实生活中,一个用户可以有多个配置文件,但没有可靠的方法从图形中提取这些数据

但是,如果您询问如何获取用户管理员的页面ID,请使用:

https://graph.facebook.com/USER_ID/accounts
这将需要给定用户的有效访问令牌