开发者

Facebook application refresh automatically

开发者 https://www.devze.com 2023-02-12 12:33 出处:网络
My application refreshs automatically to facebook login url but my user already signed in so repeats refresh, nonstop.

My application refreshs automatically to facebook login url but my user already signed in so repeats refresh, nonstop.

Here is my code

$facebook = new Facebook(array(
    'appId'  => 'my app id',
    'secret' => 'my secret key',
    'cookie' => true,
));
$session = $facebook->getSession();
$fbme = null;
$loginUrl = $facebook->getLoginUrl(
    array(
        'canvas'    => 1,
        'fbconnect' => 0,
        'next' => 'my app uri',
        'cancel_url' => 'my app uri',
        'req_perms' => 'email,publish_stream,status_update,offline_access,user_birthday'
    )
);
if (!$session) {
   echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
   exit;
}
else {
  try {
      $uid      =   $facebook->getUser();
      $fbme     =   $facebook->api('/me');
  } catch (FacebookApiException $e) {
      echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
      exit;
  }
}
function d($d){
return TRUE;
}

And my page's source in refresh is:

"<script type='text/javascript'>top.location.href = 'facebook login url..';</script>

Always refreshs, non sto开发者_如何学运维p.

I looked google and i found p3p policy: header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"'); added but not working :(

Sorry for my bad English.


I guess you need to look at this document:

Cookies in iframes/P3P Header
Some browsers will let iframes set cookies based on the presence of the P3P header. Notably, IE respects this header. Ideally you may want to look up the right value based on the privacy policy adopted by your application, but any value will usually suffice. The sample application sends this for instance:

P3P: CP="HONK"


  1. Download the latest version of the PHP-Sdk form My Apps -> your application
  2. Disable the option Stream post URL security in My App->your application->Edit Settings.

You might be using the old version of the PHP Sdk.

0

精彩评论

暂无评论...
验证码 换一张
取 消