facebook php api multiple users one computer force logout -
i working on application going operate in kiosk, point allow users while @ business able login facebook , after logging in posts message saying there, afterwords given coupon.
the problem has arisen after have logged in , logged out, next person logs in account ends posting previous user, continues adnauseum.
after getting coupon script automatically logs them out after 15 seconds , returns application home screen next user. when login, able returns them page asking permission post, pulling of previous users information. code being called in page after being sent logging in on facebook.
<?php //include facebook php sdk include_once 'coupongenerator/facebook.php'; //start session if necessary if( session_id() ) { } else { session_start(); } //instantiate facebook library app id , app secret $facebook = new facebook(array( 'appid' => '00000000000', 'secret' => '000000000000000000000', 'cookie' => true, 'status' => true, 'oath' => true )); $access_token = $facebook->getaccesstoken(); $_session['active'][$access_token]; //get news feed of active page using page's access token $page_feed = $facebook->api( '/me/feed', 'get', array( 'access_token' => $_session['active']['access_token'] ) ); $fbuser = $facebook->api('/me'); //var_dump($page_feed); exit; ?>
i have attempted on homepage of of deleting facebook cookies , sessions , has not solved anything, trying figure out doing wrong , advice welcome.
$facebook->destroysession(); $facebook->_killfacebookcookies(); public function _killfacebookcookies() { // api key $apikey = $this->getappid(); // name of cookie $cookie = $this->getsignedrequestcookiename(); $cookies = array('user', 'session_key', 'expires', 'ss'); foreach ($cookies $name) { setcookie($apikey . '_' . $name, false, time() - 3600); unset($_cookie[$apikey . '_' . $name]); } setcookie($apikey, false, time() - 3600); unset($_cookie[$apikey]); $this->clearallpersistentdata(); }
here updated connection class `
<?php //include facebook php sdk include_once 'facebook.php'; //instantiate facebook library app id , app secret $facebook = new facebook(array( 'appid' => '122628977190080', 'secret' => '123123123123123123123123', 'cookie' => true )); $access_token = $facebook->getaccesstoken(); unset ($_session['active'][$access_token]); session_unregister ($_session['active'][$access_token]); //get fb uid of logged in user $user = $facebook->getuser(); //if user has allowed application, you'll able his/her fb uid if($user) { //start session if needed if( session_id() ) { } else { session_start(); } //do stuff when logged in //get user's access token $access_token = $facebook->getaccesstoken(); //check permissions list $permissions_list = $facebook->api( '/me/permissions', 'get', array( 'access_token' => $access_token ) ); //check if permissions need have been allowed user //if not redirect them again facebook's permissions page $permissions_needed = array('publish_stream', 'email'); foreach($permissions_needed $perm) { if( !isset($permissions_list['data'][0][$perm]) || $permissions_list['data'][0][$perm] != 1 ) { $login_url_params = array( 'scope' => 'publish_stream,email', 'fbconnect' => 1, 'display' => "page", 'next' => 'http://'.$_server['http_host'].$_server['request_uri'] ); $login_url = $facebook->getloginurl($login_url_params); header("location: {$login_url}"); exit(); } } //if user has allowed permissions need, //get information pages or managers $accounts = $facebook->api( '/me/accounts', 'get', array( 'access_token' => $access_token ) ); //save information inside session $_session['access_token'] = $access_token; $_session['accounts'] = $accounts['data']; //save first page default active page $_session['active'] = $accounts['data'][0]; //redirect manage.php header('location: ../facebook_result.php'); } else { //if not, let's redirect allow page can access //create login url using facebook library's getloginurl() method $login_url_params = array( 'scope' => 'read_stream,email', 'fbconnect' => 1, 'display' => "page", 'next' => 'http://'.$_server['http_host'].$_server['request_uri'] ); $login_url = $facebook->getloginurl($login_url_params); //redirect login url on facebook header("location: {$login_url}"); exit(); }
?>`
after calling logoff script, run piece of code on homepage see if set.
<?php try { $uid = $facebook->getuser(); $fbme = $facebook->api('/me'); echo "$uid"; } catch (facebookapiexception $e) { print_r($e); } ?>
it gives me result
facebookapiexception object ( [result:protected] => array ( [error] => array ( [message] => active access token must used query information current user. [type] => oauthexception [code] => 2500 ) ) [message:protected] => active access token must used query information current user. [string:private] => [code:protected] => 0 [file:protected] => /home/m3dev/public_html/couponsite/coupongenerator/base_facebook.php [line:protected] => 1046 [trace:private] => array ( [0] => array ( [file] => /home/m3dev/public_html/couponsite/coupongenerator/base_facebook.php [line] => 751 [function] => throwapiexception [class] => basefacebook [type] => -> [args] => array ( [0] => array ( [error] => array ( [message] => active access token must used query information current user. [type] => oauthexception [code] => 2500 ) ) ) ) [1] => array ( [function] => _graph [class] => basefacebook [type] => -> [args] => array ( [0] => /me ) ) [2] => array ( [file] => /home/m3dev/public_html/couponsite/coupongenerator/base_facebook.php [line] => 560 [function] => call_user_func_array [args] => array ( [0] => array ( [0] => facebook object ( [appid:protected] => 162628977190080 [apisecret:protected] => **secret key removed ** [user:protected] => 0 [signedrequest:protected] => array ( [algorithm] => hmac-sha256 [code] => 961628b1ca0354544541d58e.1-34319949|p3d3psnoawlc1wbllhin7zoepjy [issued_at] => 1331218933 [user_id] => 34319949 ) [state:protected] => [accesstoken:protected] => 162628977190080|**secret key removed** [fileuploadsupport:protected] => ) [1] => _graph ) [1] => array ( [0] => /me ) ) ) [3] => array ( [file] => /home/m3dev/public_html/couponsite/index.php [line] => 71 [function] => api [class] => basefacebook [type] => -> [args] => array ( [0] => /me ) ) ) )
you may destroying facebook session don't seem destroying own session.
clear out
$_session['active'][$access_token];
Comments
Post a Comment