2012-12-06 103 views
0

通過Facebook連接第一次登錄我的網站的用戶重定向到一個php腳本,該腳本應該邀請他們加入我的社團facebook小組。邀請用戶加入facebook羣

<?php 
require_once "facebook_sdk/src/facebook.php"; 

$app_id = 'xxxxxxx'; 
$app_secret = 'xxxxxxx'; 

// Init facebook api. 
$facebook = new Facebook(array(
    'appId' => $app_id, 
    'secret' => $app_secret, 
    'cookie' => true 
)); 

// Get the url to redirect for login to facebook 
$login_url = $facebook->getLoginUrl(
    array('scope' => 'manage_pages') 
); 

// If not authenticated, redirect to the facebook login dialog. 
// The $login_url will take care of redirecting back to us 
// after successful login. 
if (! $facebook->getUser()) { 
    echo <<< EOT 
<script type="text/javascript"> 
top.location.href = "$login_url"; 
</script>; 
EOT; 

    exit; 
} 

$token=$facebook->getAccessToken(); 
echo $token . "</br>"; 
$user=$facebook->getUser(); 
$page = "/45277909073/members/" . $user . "/"; 
echo $page; 

$facebook->api($page, "post",array('access_token='=>$token)); 
?> 

此代碼輸出以下
173863136082149 | 9f42756f3760ff697b3c4e809bfe48f7
/45277909073 /構件/ 987654321/
致命錯誤:未捕獲OAuthException:用戶訪問令牌需要請求此資源。在/home/somewhere/public_html/fb/facebook_sdk/src/base_facebook.php扔在線路1238

伊夫根據本上的數獨下邀請用戶部分
https://developers.facebook.com/docs/reference/api/group/

回答

1

'access_token=' => $token 

它應該是

'access_token' => $token 
相關問題