开发者

Having a problem in redirect to the canvas page

I'm new in FB and having a problem.

I want to put an application in Facebook and already have a website and database. The application could be displayed in Facebook no matter whether the user logged in or not. In order to show the application only to the logged in user, I add some code:

if (!$session){
    $url = $facebook->getLoginUrl(array(
            'cavas' => 1,
            'fbconnet' => 0
    ));

    echo "<script type='text/javascript'>开发者_Python百科;top.location.href = '$url';</script>";
}
else {
    try {
        $uid = $facebook->getUser();
        $me  = $facebook->api('/me');
    } catch (FacebookApiException $e){
        error_log($e);
    }
}

But when a user logs in and redirects to my site, the page didn't successfully load. How can I solve it? (The old code is written like below and runs well except for the login problem:

if ($session){

    try {
        $uid = $facebook->getUser();
        $me  = $facebook->api('/me');
    } catch (FacebookApiException $e){
        error_log($e);
    }
}


Use next and it's canvas not cavas:

if (!$session){
    $url = $facebook->getLoginUrl(array(
            'canvas' => 1,
            'next' => 'http://apps.facebook.com/CANVAS_NAME',
            'fbconnet' => 0
    ));

    echo "<script type='text/javascript'>top.location.href = '$url';</script>";
}
else {
    try {
        $uid = $facebook->getUser();
        $me  = $facebook->api('/me');
    } catch (FacebookApiException $e){
        error_log($e);
    }
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜