Closed Fynkymynky closed 8 years ago
OK, think I have found the issue. I'm storing the tokens for both twitter and facebook in a database. But I've been keeping my browser open which has kept the session alive. So when I logged back into my app with the facebook button the session for twitter no longer exists. Is there a way to set the session for twitter from the values in the database? Thanks
i have tried this way...
public function loginWithTwitter() {
// get data from input
$token = Input::get('oauth_token');
$verify = Input::get('oauth_verifier');
// get twitter service
$tw = OAuth::consumer('Twitter', 'http://localhost:8000/oauth/twitter');
// check if code is valid
// if code is provided get user data and sign in
if (!empty($token) && !empty($verify)) {
try {
if (!isset($_SESSION['token'])) {
// This was a callback request from twitter, get the token
$token = $tw -> requestAccessToken($token, $verify);
$_SESSION['token'] = $token -> getAccessToken();
}
} catch(Exception $e) {
return Redirect::to('oauth/user');
}
// Send a request with it
$result = json_decode($tw -> request('account/verify_credentials.json'), true);
$message = 'Your unique Twitter user id is: ' . $result['id'] . ' and your name is ' . $result['name'];
echo $message . "<br/>";
SocialData::storeTwitterData($result);
//Var_dump
//display whole array().
var_dump($result);
echo "<a href='logout'>Logout</a>";
}
// if not ask for permission first
else {
// get request token
$reqToken = $tw -> requestRequestToken();
// get Authorization Uri sending the request token
$url = $tw -> getAuthorizationUri(array('oauth_token' => $reqToken -> getRequestToken()));
// return to twitter login url
return Redirect::to((string)$url);
}
}
I'm getting this error a lot now