2011-10-27 38 views

回答

5

您所說的oauth_token也是用戶access_token,它們應該完全相同。

要檢查用戶權限,你可以做一個GET調用/ ME /權限,應返回下面

{ 
    "data": [ 
    { 
     "installed": 1, 
     "read_stream": 1, 
     "manage_notifications": 1, 
     "manage_pages": 1, 
     "user_likes": 1, 
     "user_activities": 1, 
     "user_interests": 1, 
     "user_photos": 1, 
     "user_about_me": 1, 
     "type": "permissions" 
    } 
    ] 
} 

類似數據陣列根據您所希望的其他數據訪問,您將需要要求更多權限,然後調用適當的API端點。例如,要獲得用戶的基本信息,撥打電話到/me或得到他們的朋友列表/me/friends

你可以找到你可以要求在https://developers.facebook.com/docs/reference/api/permissions/

的所有權限和所有在哪裏調用信息在API中用於檢索您在此處需要的不同位數據https://developers.facebook.com/docs/reference/api/

1

當你說你有他們的'oauth令牌' - 你確定這不是訪問令牌嗎?您可以嘗試使用該標記對/me/permissions進行API調用,看看它是否正常工作?它應該返回用戶授予您的應用程序的權限列表(可通過該令牌使用)

-1
<?php 
include '../../src/config.php'; 
// Get User ID 
$user = $facebook->getUser(); 

// We may or may not have this data based on whether the user is logged in. 
// 
// If we have a $user id here, it means we know the user is logged into 
// Facebook, but we don't know if the access token is valid. An access 
// token is invalid if the user logged out of Facebook. 

if ($user) { 
    try { 
    // Proceed knowing you have a logged in user who's authenticated. 
    $user_profile = $facebook->api('/me'); 
    } catch (FacebookApiException $e) { 
    error_log($e); 
    $user = null; 
    } 
} 

// Login or logout url will be needed depending on current user state. 
if ($user) { 
    $logoutUrl = $facebook->getLogoutUrl(); 
    $access_token = $facebook->getAccessToken(); 
$user_xml = "<?xml version=\"1.0\"?>\n"; 
$user_xml .= "<roots>\n"; 
$user_xml .= "<access>\n"; 
$user_xml .= "<token>" . $access_token . "</token>\n"; 
$user_xml .= "</access>\n"; 
$user_xml .= "</roots>\n"; 
echo $user_xml; 



} else { 
    $loginUrl = $facebook->getLoginUrl(); 
} 




?> 
相關問題