2011-11-21 79 views
0

我最近更改了網絡主機。從那以後,我一直收到Facebook的用戶名爲0:Facebook用戶ID始終爲0

<?php 
$app_id = "xxxxxxxx"; 
$canvas_page = "http://apps.facebook.com/the_rsg/"; 
$auth_url = "http://www.facebook.com/dialog/oauth?client_id=".$app_id."&redirect_uri=".urlencode($canvas_page); 
$signed_request = $_REQUEST["signed_request"]; 

list($encoded_sig, $payload) = explode('.', $signed_request, 2); 

$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true); 

if (empty($data["user_id"])) { 
    echo("<script> top.location.href='".$auth_url."'</script>"); 
}else{ 
    $pageContent = file_get_contents('http://graph.facebook.com/'.$data["user_id"]); 
    $parsedJson = json_decode($pageContent); 
    $user_id = $parsedJson->id; 
    $user_name = $parsedJson->name; 
    session_start(); 
    $_SESSION['UserID'] = $user_id; 
} 
?> 

這怎麼解決?

+0

是否正確更改Facebook應用的基本設置? –

+0

是的,我做了,更改了畫布URL –

+0

其餘數據是否正確返回? – JohnP

回答

1

在檢查錯誤日誌:

PHP的警告:的file_get_contents(http://graph.facebook.com/xxxxx)function.file-GET-內容]:

未能打開流:沒有合適的包裝可以在/ home/jay/public_html/index.php在線20找到

問題出在php.ini文件。

解決方法是啓用allow_url_fopen