webhost

Web hosting

Wednesday, March 28, 2012

Solution for facebook logouturl not working

we can get the user information,facebook loginUrl and logoutUrl from the below code using facebook SDK. but now the logoutUrl is not working in facebook by using below code 



$config = array(
            
'appId'  => '1234',
            
'secret' => '123456789','fileUpload' => true// Indicates if the CURL based @ syntax for file uploads is enabled. $user_id $facebook->getUser();
        
// We may or may not have this data based on whether the user is logged in.
        //
        // If we have a $user id here, it means we know the user is logged into
        // Facebook, but we don't know if the access token is valid. An access
        // token is invalid if the user logged out of Facebook.
$profile null;

if($user_id)
     {
    
$userInfos   $facebook->api('/'.$user);
            try {
                
// Proceed knowing you have a logged in user who's authenticated.
    
$profile $facebook->api('/me?fields=id,name,link,email');
                
$fql    =   "select name, location, sex, pic_square from user where uid=" $user;
            
$param  =   array(
                
'method'    => 'fql.query',
                
'query'     => $fql,
                
'callback'  => ''
            
);
  
$fb_data = array(
                  
'me' => $profile,
                  
'uid' => $user_id,
                  
'loginUrl' => $facebook->getLoginUrl(),
                  
'logoutUrl' => $facebook->getLogoutUrl(),
                    );
                    <
del></del>print_r($fb_data); 




The above fetch logourUrl is not working

if try below code ie to find facebook logoutUrl separate. its a valid logoutUrl its working for me






function get_logout_url(){//return the facebook logoutUrl

    
return  $facebook->getLogoutUrl();








5 comments:

  1. I see you use array scope in getLogoutUrl. I think this only is for use with getLogin do you know because is that?=

    ReplyDelete
    Replies
    1. yes no need of array scope in logouturl(). thank u

      Delete
  2. In codeigniter, I have fixed it.
    The cookie name is PHPSESSID

    http://ashish-thakur.blogspot.in/2012/07/facebook-php-sdk-logout-resolved.html

    ReplyDelete
  3. Added the session_destroy() in getLogoutUrl function.

    ReplyDelete