簡體   English   中英

Facebook API如何獲取用戶頁面

[英]Facebook API how to get User Pages

我使用以下代碼來獲取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

這將需要給定用戶的有效訪問令牌。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM