1

我正在尝试使用 PHP 和 Facebook 进行简单的登录。问题是当它应该显示“iframe”、“popup”或“page”时我有这个结果(它们都不起作用)

API Error Code: 102
API Error Description: Session key invalid or no longer valid
Error Message: Iframe dialogs must be called with a session key

我现在使用的代码是这样的:

$config = array(
    'appId' => 'CODE1',
    'secret' => 'CODE2',
    'cookie' => true
);

$params = array(
    'redirect_uri' => 'http://domain.dev',
    'display'=>'iframe'
);

$facebook = new Facebook($config);

$user = $facebook->getUser();
if ($user) {
    //something
} else {
    $user = null;
    $loginUrl = $facebook->getLoginUrl($params);    
    //redirect to loginURL                  
}
4

1 回答 1

2

试试这个 :

if (!(isset($_REQUEST['state'])) {
    $loginUrl = $facebook->getLoginUrl(array(
        'redirect_uri' => 'http://domain.dev',
        'display' => 'popup',
        'scope' => 'user_photos'
            ));
    echo $loginUrl;

如需更多参考,您可以使用:

http://www.9lessons.info/2011/02/login-with-facebook-and-twitter.html

于 2013-02-07T14:13:53.480 回答