Facebook 用户 ID 始终为 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;
}
?>
如何解决此问题?
I've recently changed webhosts. Since then, I keep getting 0 for the Facebook User ID:
<?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;
}
?>
How can this be fixed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查错误日志时:
问题出在 php.ini 文件中。
解决方案是启用
allow_url_fopen
。On checking the error log:
The problem is in the php.ini file.
The solution is to enable
allow_url_fopen
.