简体   繁体   English

将用户重定向到facebook应用程序中的另一个php页面无法正常工作

[英]redirect user to another php page in facebook app not working properly

I'm new to facebook app developing and I want to redirect users after they click a button in the app. 我是Facebook应用开发的新手,我想在用户单击应用中的按钮后重定向用户。 I am using some thing like below: 我正在使用类似下面的东西:

   <?
   echo '<script> location.href="help.php";</script>';
   ?>

in the help.php on top of the page I have below code and I put exit; 在页面顶部的help.php中,我有下面的代码,我退出了; to test whether this part is working fine: 测试这部分是否工作正常:

      <?php
      ini_set('display_errors', 1);
      error_reporting(E_ALL);
      require_once("./config.php");
      $me = $facebook->api('/me');
      $access_token = $facebook->getAccessToken();
      $user = $facebook->getUser();
      echo "access token:".$access_token;
      echo "<br/> user:".$user;
      exit;
      ?>

the redirect is not working properly!! 重定向无法正常工作! it is showing blank page once upon a time and the code is not reliable for production. 它曾经显示空白页,并且代码对于生产不可靠。 do you have any idea what is wrong here? 你知道这里有什么问题吗?

UPDATED: this the error i get: Fatal error: Uncaught OAuthException: An active access token must be used to query information about the current user. 更新:这是我得到的错误:致命错误:未捕获的OAuthException:必须使用活动访问令牌来查询有关当前用户的信息。

Are you sure its the right order for these? 您确定其正确的顺序吗?

 $me = $facebook->api('/me');
  $access_token = $facebook->getAccessToken();
  $user = $facebook->getUser();

Try this 尝试这个

$access_token = $facebook->getAccessToken();
$user = $facebook->getUser();     
$me = $facebook->api('/me');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM