页面选项卡内的oauth facebook重新加载

页面选项卡内的oauth facebook重新加载,facebook,oauth,reload,Facebook,Oauth,Reload,我在facebook上有一个应用程序,我只使用页面标签,一切正常。我点击像,我允许应用程序,请求权限,我允许,但现在它回到页面,有一个错误,它重新加载了一遍又一遍。。。页面无法加载,因为浏览器总是重新加载,我不知道如何修复它 非常感谢 这是我的密码: <?php require_once "sdk/facebook.php"; $app_id = "MY_APPID"; $app_secret = "MY_SECRET"; $is_fan = false; // Init face

我在facebook上有一个应用程序,我只使用页面标签,一切正常。我点击像,我允许应用程序,请求权限,我允许,但现在它回到页面,有一个错误,它重新加载了一遍又一遍。。。页面无法加载,因为浏览器总是重新加载,我不知道如何修复它

非常感谢

这是我的密码:

<?php

require_once "sdk/facebook.php";

$app_id = "MY_APPID";
$app_secret = "MY_SECRET";

$is_fan = false;

// Init facebook api.
$facebook = new Facebook(array(
    'appId' => $app_id,
    'secret' => $app_secret,
    'cookie' => true
));

// Get and decode signed request.
$signed_request = $facebook->getSignedRequest();
if (isset($_REQUEST['signed_request'])) {
    $encoded_sig = null;
    $payload = null;
    list($encoded_sig, $payload) = explode(
        '.', $_REQUEST['signed_request'], 2
    );
    $sig = base64_decode(strtr($encoded_sig, '-_', '+/'));
    $data = json_decode(
        base64_decode(strtr($payload, '-_', '+/'), true)
    );
    $signed_request = $data;
}
else {
    $signed_request = false;
}

// Determine if we have a fan request.
if($signed_request) {
    if($signed_request->page->liked) {
        $is_fan = true;
    }
}

// for fans
if ($is_fan) { ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="css/style.css" rel="stylesheet" type="text/css" />       

    <script>
      var oauth_url = 'https://www.facebook.com/dialog/oauth/';
      oauth_url += '?client_id=414328901957674';
      oauth_url += '&redirect_uri=' + encodeURIComponent('https://www.facebook.com/pages/null/167838393340757/?sk=app_414328901957674');
      oauth_url += '&scope=user_birthday,user_likes,photo_upload,publish_stream,user_about_me,user_photos,user_hometown,user_location'

      window.top.location = oauth_url;
    </script>

    </head>
    <body background="images/fanda.jpg" style="overflow:hidden;"">
      </body>

<?php }

// for non-fans
else { ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="css/style.css" rel="stylesheet" type="text/css" />       
    </head>
     <body background="images/klikni-like.jpg" style="overflow:hidden;">
     </body>

<?php } ?>

var oauth_url='1〕https://www.facebook.com/dialog/oauth/';
oauth_url+='?客户机_id=414328901957674';
oauth_url+='&重定向_uri='+encodeURIComponent('https://www.facebook.com/pages/null/167838393340757/?sk=app_414328901957674');
oauth\u url+='&范围=用户生日、用户喜好、照片上传、发布流、用户关于我、用户照片、用户家乡、用户位置'
window.top.location=oauth\u url;

当某人是你的粉丝时,你的剧本总是在做:


如果有人是粉丝,这将导致页面无限重新加载。

我找到了解决您问题的方法。检查($is\u fan)时更新此项:

$user\u id=$facebook->getUser();
如果($是_fan){
if($user\u id)
{
验证后的代码和页面
}
}
否则{
var oauth_url='1〕https://www.facebook.com/dialog/oauth/';
与上述代码相同的接下来4行。。。。。。。。。。。。。。
}
window.top.location = oauth_url;
$user_id = $facebook->getUser();
if ($is_fan) {  
      if($user_id)
          {
               code after authentication and page Liked
          }

             }
else  {
          <script>
              var oauth_url = 'https://www.facebook.com/dialog/oauth/';
              ................ Next 4 lines same as the above code ..............
          </script>
      }