Facebook application refresh automatically

ぃ、小莉子 提交于 2019-11-30 21:19:55

问题


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 stop.

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.


回答1:


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"



回答2:


  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.



来源:https://stackoverflow.com/questions/5083484/facebook-application-refresh-automatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!