首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >身份验证令牌facebook php错误

身份验证令牌facebook php错误
EN

Stack Overflow用户
提问于 2011-10-06 05:25:52
回答 1查看 2.2K关注 0票数 0

这很奇怪,因为在我的facebook应用程序的画布页面上,我得到了关于我的auth_token的所有这些php错误,然后它重定向并正常工作。有人能帮我解决这个问题吗?这是我在页面顶部的php代码:

代码语言:javascript
复制
$app_id = "181247432419054";
$app_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$my_url = "https://apps.facebook.com/wellnessq/";
session_register();
session_start();


if (!isset($_REQUEST["code"]))
{
 $_SESSION['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection
 $dialog_url = "http://www.facebook.com/dialog/oauth?client_id=" 
   . $app_id . "&redirect_uri=" . urlencode($my_url) . "&scope=email&state="
   . $_SESSION['state'];

 echo("<script> top.location.href='" . $dialog_url . "'</script>");
 }
 $code = $_REQUEST['code'];
{
 $token_url = "https://graph.facebook.com/oauth/access_token?"
   . "client_id=" . $app_id . "&redirect_uri=" . urlencode($my_url)
   . "&client_secret=" . $app_secret . "&code=" . $code;

 $response = file_get_contents($token_url);
 $params = null;
 parse_str($response, $params);

 $graph_url = "https://graph.facebook.com/me?access_token=" 
   . $params['access_token'];

 $user = json_decode(file_get_contents($graph_url));
}

?> 

第一条错误消息开始于$code =$_REQUEST‘$code’;然后是更多的错误消息。我无法发布屏幕截图,因为我的名誉点太少=/ grrr,但以下是错误消息:

注意:未定义索引: D:\Extranet\www.mysite.com\manager\here\core.functions.php(663):eval()中的代码第19行

警告: file_get_contents(https://graph.facebook.com/oauth/access_token?client_id=181247432419054&redirect_uri=https%3A%2F%2Fapps.facebook.com%2Fwellnessq%2F&client_secret=xxxxxxxxxxxxxxxxx&code=)函数.file-get-contents:无法打开流: HTTP请求失败!D:\Extranet\www.mysite.com\manager\here\core.functions.php(663)中的HTTP/1.0400错误请求:第25行的eval()d代码

注意:第30行的D:\Extranet\www.mysite.com\manager\here\core.functions.php(663):eval()d代码中未定义索引: access_token

警告: file_get_contents(https://graph.facebook.com/me?access_token=)函数.file-get-contents:无法打开流: HTTP请求失败!D:\Extranet\www.mysite.com\manager\here\core.functions.php(663)中的HTTP/1.0 400错误请求:第32行的eval()d代码

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-10-06 07:44:26

您需要在回显<script>标记之后立即添加一条exit;语句。我在很多Facebook示例代码中都注意到了这个疏忽。通常这不会造成太多问题,但是一旦你确定你需要重定向,你应该确保你停止做任何其他事情,并给浏览器时间来处理重定向脚本。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7667941

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档