Я пытаюсь интегрировать функциональность в webapp, где пользователь нажимает кнопку, чтобы чирикать, насколько удивительным является webapp. (Я знаю, я знаю, глупый, но эй, босс хочет)Как обрабатывать аутентификацию Twitter?
настроить маршрут ниже с использованием Twitter Thujohn для Laravel 4 - https://github.com/thujohn/twitter-l4
Route::get('/twitter/callback', function() {
// You should set this route on your Twitter Application settings as the callback
// https://apps.twitter.com/app/YOUR-APP-ID/settings
if(Session::has('oauth_request_token')) {
$request_token = array(
'token' => Session::get('oauth_request_token'),
'secret' => Session::get('oauth_request_token_secret'),
);
Twitter::set_new_config($request_token);
$oauth_verifier = FALSE;
if(Input::has('oauth_verifier')) {
$oauth_verifier = Input::get('oauth_verifier');
}
// getAccessToken() will reset the token for you
$token = Twitter::getAccessToken($oauth_verifier);
if(!isset($token['oauth_token_secret'])) {
return Redirect::to('/')->with('flash_error', 'We could not log you in on Twitter.');
}
$credentials = Twitter::query('account/verify_credentials');
if(is_object($credentials) && !isset($credentials->error)) {
// $credentials contains the Twitter user object with all the info about the user.
// Add here your own user logic, store profiles, create new users on your tables...you name it!
// Typically you'll want to store at least, user id, name and access tokens
// if you want to be able to call the API on behalf of your users.
// This is also the moment to log in your users if you're using Laravel's Auth class
// Auth::login($user) should do the trick.
var_dump($credentials);
//return Redirect::to('/')->with('flash_notice', "Congrats! You've successfully signed in!");
}
return Redirect::to('/')->with('flash_error', 'Crab! Something went wrong while signing you up!');
}
});
Однако, я не знаю, что я должен делать в этой части:
// $credentials contains the Twitter user object with all the info about the user.
// Add here your own user logic, store profiles, create new users on your tables...you name it!
// Typically you'll want to store at least, user id, name and access tokens
// if you want to be able to call the API on behalf of your users.
// This is also the moment to log in your users if you're using Laravel's Auth class
// Auth::login($user) should do the trick.
Что мне нужно сделать, чтобы убедиться, что пользователь не должен аутентифицировать себя каждый раз?
Ну, я сделал var_dump, и я не смог найти их там .... – user4191537
Добавьте пакет, например raveren/kint, чтобы проверить полный класс - они могут быть не общедоступными и доступны только с помощью метода getToken() или похожие. дамп Kint покажет вам доступные методы, которые вы можете использовать, чтобы вытащить эту информацию. – Laravelian