开发者

PHP loop issues with facebook app auth

I am using the latest PHP-SDK(3.11) and i have issues when users come on my app for the first time. The application make infinite loops. When the user have to give permissions to the application, he is redirected to :

https://www.facebook.com/connect/uiserver.php?app_id=**myappId**&method=permissions.request&display=page&next=http%3A%2F%2Fapps.facebook.com%2F**myApp**%2F&response_type=code&state=**theSate**&canvas=1&perms=user_birthday%2Cuser_location%2Cuser_work_history%2Cuser_about_me%2Cuser_hometown

and when he accept i have the following link returned :

http://apps.facebook.com/**myApp**/?error_reason=user_denied&error=access_denied&error_description=***The+user+denied+your+request.***&state=**theSate**#_

i don't understand why the access is denied when the user click on "allow".

if ($this->fbUser) {
         开发者_JAVA百科   .... Do Somthing
        } else {
            $this->loginUrl = $this->fb->facebook->getLoginUrl(array(
                        'scope' => implode(',', sfConfig::get('app_facebook_perms')
            ), 'next' => 'http://apps.facebook.com'. sfConfig::get('app_facebook_app_url')));


            $this->logMessage($this->loginUrl, 'info');
            sfConfig::set('sf_escaping_strategy', false);
        }

        <script type='text/javascript'>
            top.location.href = "echo $this->loginUrl ";
        </script>


Try something like this, since you need to store the access token, one way or another. Hard to know what you are doing (or not doing) from that snippet.

<?php  
# We require the library  
require("facebook.php");  

# Creating the facebook object  
$facebook = new Facebook(array(  
    'appId'  => 'APP_ID_HERE',  
    'secret' => 'APP_SECRET_HERE',  
    'cookie' => true  
));  

# Let's see if we have an active session  
$session = $facebook->getUser();  

if(empty($session)) {  
    # There's no active session, let's generate one  
    $url = $facebook->getLoginUrl(array(  
        "response_type"=>"token", //Can also be "code" if you need to 
        "scope" => 'email,user_birthday,status_update,publish_stream,user_photos,user_videos' , 
        "redirect_uri"=> "http://test.com" //Your app callback url 
    ));  
    header("Location: $url");  
    exit;  
}  
// user is logged in  
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜