duanliao6789
2015-06-16 09:11
浏览 165
已采纳

Facebook应用程序在Facebook页面内获取身份验证

I have a facebook page I have built an application to be in the page tab the application works fine with the original url it get the login from the facebook and return to the url

how i can get the authintication from the user without changing the url "inside the iframe" ?

require_once("facebook.php");
$facebook = new Facebook(array(
        'appId' => 'App_id',
        'secret' => 'Secret'));
$current_user = $facebook->getUser();

$params = array('scope' =>'email,user_likes,user_friends');
if ($current_user) { 
    try {
            $expiration = time() + 172800; 
            $cookie_value = $current_user . '|' . $expiration;
            setcookie('fbid', $cookie_value, $expiration , "/");
            echo '<script type="text/javascript">
            window.location = "like.php";
            </script>';
    } catch (FacebookApiException $e) {
        $login_url = $facebook->getLoginUrl($params);
        echo '<script type="text/javascript">
        window.location = "' . $login_url . '";
        </script>';
        exit;
        error_log($e->getType());
        error_log($e->getMessage());
    }
} else {
    $login_url = $facebook->getLoginUrl($params);
    echo '<script type="text/javascript">
        window.location = "'.$login_url.'";
        </script>';
    exit;
}

图片转代码服务由CSDN问答提供 功能建议

我有一个facebook页面 我已经在页面选项卡中构建了一个应用程序 应用程序正常工作 原始url it从facebook获取登录并返回url </ p>

如何在不更改“iframe内部”网址的情况下从用户获取authintication?</ p> \ n

  require_once(“facebook.php”); 
 $ facebook = new Facebook(array(
'appId'=&gt;'App_id',
'secret'=&gt;'Secret  ')); 
 $ current_user = $ facebook-&gt; getUser(); 
 
 $ params = array('scope'=&gt;'email,user_likes,user_friends'); 
if($ current_user){\  n尝试{
 $ expiration = time()+ 172800;  
 $ cookie_value = $ current_user。  '|'  。  $ expiration; 
 setcookie('fbid',$ cookie_value,$ expiration,“/”); 
 echo'&lt; script type =“text / javascript”&gt; 
 window.location =“like.php”;  
&lt; / script&gt;'; 
} catch(FacebookApiException $ e){
 $ login_url = $ facebook-&gt; getLoginUrl($ params); 
 echo'&lt; script type =“text / javascript”&gt  ; 
 window.location =“'。$ login_url。'”; 
&lt; / script&gt;'; 
退出; 
 error_log($ e-&gt; getType()); 
 error_log($ e-  &gt; getMessage()); 
} 
} else {
 $ login_url = $ facebook-&gt; getLoginUrl($ params); 
 echo'&lt; script type =“text / javascript”&gt; 
 window  .location =“'。$ login_url。'”; 
&lt; / script&gt;'; 
退出; 
} 
 </ code> </ pre> 
 </ div>

1条回答 默认 最新

相关推荐 更多相似问题