Php Firefox无法使用facebook api邀请、张贴在墙上

Php Firefox无法使用facebook api邀请、张贴在墙上,php,facebook,firefox,facebook-graph-api,facebook-javascript-sdk,Php,Facebook,Firefox,Facebook Graph Api,Facebook Javascript Sdk,下面的代码在chrome和IE上运行得非常好,但是当我用Firefox测试它时,它返回了一个错误“发生了一个错误,请稍后再试”。我想知道代码中的问题是什么,下面是与Facebook API相关的代码 $user_id = $facebook->getUser(); if ($user_id) { try { // Fetch the viewer's basic information $basic = $facebook->api('/me'); } cat

下面的代码在chrome和IE上运行得非常好,但是当我用Firefox测试它时,它返回了一个错误“发生了一个错误,请稍后再试”。我想知道代码中的问题是什么,下面是与Facebook API相关的代码

$user_id = $facebook->getUser();
if ($user_id) {
  try {
    // Fetch the viewer's basic information
    $basic = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    // If the call fails we check if we still have a user. The user will be
    // cleared if the error is because of an invalid accesstoken
    if (!$facebook->getUser()) {
      header('Location: '. AppInfo::getUrl($_SERVER['REQUEST_URI']));
      exit();
    }
  }
if (check_user($user_id,$promo) && check_friend($user_id)>0){ 
    header('Location: Thankyou.php');
}
if (!check_promo()){
    header('Location: Thankyou.php');
}


// Fetch the basic info of the app that they are using
$app_info = $facebook->api('/'. AppInfo::appID());
$app_name = idx($app_info, 'name', '');
?>


<!DOCTYPE html>
<html xmlns:fb="http://ogp.me/ns/fb#" lang="en">
  <head>
    <script type="text/javascript">
      function logResponse(response) {
        if (console && console.log) {
          console.log('The response was', response);
        }
      }



     //Perhaps the problem come from here
      $(function(){
        // Set up so we handle click on the buttons
        $('#postToWall').click(function() {
          FB.ui(
            {
              method : 'feed',
              link   : $(this).attr('data-url')
            },
            function (response) {
              // If response is null the user canceled the dialog
              if (response != null) {
                logResponse(response);
              }
            }
          );
        });

        $('#sendRequest').click(function() {
          FB.ui(
            {
              method  : 'apprequests',
              message : $(this).attr('data-message')
            },
            function (response) {
              // If response is null the user canceled the dialog
              if (response != null) {
                var request_ids = [];
                var friend_ids = [];
                for(i=0; i<response.to.length; i++) {
                    //var temp = response.to[i] + '_' + response.to[i].name;
                    request_ids.push(response.request);
                    friend_ids.push(response.to[i]);
                }
                var requests = request_ids.join(',');
                var friends = friend_ids.join(',');
                $.post('friend_handler.php',{uid: <?php echo $user_id; ?>, fid: friends, rid: requests},function(resp) {
                    });
              }
            }
          );
        });
      });
    </script>

<?php $caption = "Hello";
$description = "Byebye";
?>
<script> 
      FB.init({appId: "<?php echo AppInfo::appID(); ?>", status: true, cookie: true});
      function postToFeed() {
        // calling the API ...
        var obj = {
          method: 'feed',
          link: 'http://apps.facebook.com/mas-amazing-journey/',
          picture: 'http://www.xman.com/content/mas-admin/my/en/site-configuration/homepagethreatre/book/AmazingWorldwideDeals/_jcr_content/contentpar/masimage_9126.img.jpg/1339349457238.jpg',
          name: 'Amazing Journey',
          caption: '<?php echo $caption; ?>',
          description: '<?php echo $description; ?>'
        };
        function callback(response) {
          document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
        }
        FB.ui(obj, callback);
      }
    </script>
    <!--[if IE]>
      <script type="text/javascript">
        var tags = ['header', 'section'];
        while(tags.length)
          document.createElement(tags.pop());
      </script>
    <![endif]-->
    <script src="//connect.facebook.net/en_US/all.js"></script>



  </head>
<body>
<header class="clearfix">
        <div id="fb-root"></div>
            <script type="text/javascript">
      window.fbAsyncInit = function() {
        FB.init({
          appId      : '<?php echo AppInfo::appID(); ?>', // App ID
          channelUrl : '//<?php echo $_SERVER["HTTP_HOST"]; ?>/channel.html', // Channel File
          status     : true, // check login status
          cookie     : true, // enable cookies to allow the server to access the session
          xfbml      : true // parse XFBML
        });

        // Listen to the auth.login which will be called when the user logs in
        // using the Login button
        FB.Event.subscribe('auth.login', function(response) {
          // We want to reload the page now so PHP can read the cookie that the
          // Javascript SDK sat. But we don't want to use
          // window.location.reload() because if this is in a canvas there was a
          // post made to this page and a reload will trigger a message to the
          // user asking if they want to send data again.
          window.location = window.location;
        });

        FB.Canvas.setAutoGrow();
      };

      // Load the SDK Asynchronously
      (function(d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) return;
        js = d.createElement(s); js.id = id;
        js.src = "//connect.facebook.net/en_US/all.js";
        fjs.parentNode.insertBefore(js, fjs);
      }(document, 'script', 'facebook-jssdk'));
    </script>
      <?php if (isset($basic)) { ?>
        <p id="picture" style="background-image: url(https://graph.facebook.com/<?php echo he($user_id); ?>/picture?type=normal)"></p>

        <h1>Welcome, <strong><?php echo he(idx($basic, 'name')); ?></strong></h1>
        <p class="tagline">
          Good Luck!
        </br>
        </p>
       <div id="share-app">
<!--          <p>Tools for your to invite your friends and spread your words:</p>-->
          <ul>
            <li>
                <a href="#" class="facebook-button" onclick='postToFeed(); return false;' >
                <span class="plus">Share this on my wall</span>
              </a>
            </li>  
<!--            <li>
              <a href="#" class="facebook-button speech-bubble" id="sendToFriends" data-url="<?php echo AppInfo::getUrl(); ?>">
                <span class="speech-bubble">Share Your Amazing Journey</span>
              </a>
            </li>-->
            <li>
              <a href="//<?php echo $_SERVER["HTTP_HOST"]; ?>/Thankyou.php" class="facebook-button speech-bubble" id="thankyou">
                <span class="speech-bubble">SUBMIT</span>
              </a>
            </li>
          </ul>
            <li>

              <a href="#" class="facebook-button apprequests" id="sendRequest" 
                 data-message="I have just invited you to fly with me">
            <span class="apprequests"><img border="0" class="facebook-button apprequests" id="sendRequest" src="http://i.imgur.com/lRdP3.jpg" style="width: 680px;margin-top:10px;z-index: -9999;"/></span>
                        </a>
            </li>
                      </div>
        <div id="guides"></div>

      <?php } else { ?>
      <section id="get-started">
      <p>Oops, You're out of track... Please reload the page to start over!</p>
      </section>
      <?php } ?>
    </header>
</body>
</html>
$user\u id=$facebook->getUser();
if($user\u id){
试一试{
//获取查看者的基本信息
$basic=$facebook->api('/me');
}捕获(FacebookApiException$e){
//如果呼叫失败,我们将检查是否还有用户。该用户将
//如果错误是由无效的accesstoken引起的,则清除该错误
如果(!$facebook->getUser()){
标题($Location:'.AppInfo::getUrl($\u SERVER['REQUEST\u URI']);
退出();
}
}
如果(check_user($user_id,$promo)和check_friend($user_id)>0){
标题('Location:Thankyou.php');
}
如果(!check_promo()){
标题('Location:Thankyou.php');
}
//获取他们正在使用的应用程序的基本信息
$app_info=$facebook->api('/'.AppInfo::appID());
$app_name=idx($app_info,'name','');
?>
功能日志响应(响应){
if(console&&console.log){
log('响应是',响应);
}
}
//也许问题就出在这里
$(函数(){
//设置以便我们处理单击按钮
$('#postToWall')。单击(函数(){
FB.ui(
{
方法:“提要”,
链接:$(this.attr('data-url'))
},
功能(响应){
//如果响应为null,则用户取消了该对话框
if(响应!=null){
对数响应(响应);
}
}
);
});
$('#sendRequest')。单击(函数(){
FB.ui(
{
方法:“apprequests”,
消息:$(this.attr('data-message'))
},
功能(响应){
//如果响应为null,则用户取消了该对话框
if(响应!=null){
var请求_id=[];
var friend_id=[];

对于(i=0;idid)您是否登录facebook并在firefox上获得访问令牌/权限?是的,我在上一页中获得了访问令牌/权限,当继续下一页时,我注意到身份验证令牌丢失,但为什么我可以在chrome中解析令牌而不能在firefox中解析令牌?我应该如何将其解析到第二页?