Exemplo n.º 1
0
 public function login()
 {
     // your SIGN IN WITH TWITTER  button should point to this route
     $sign_in_twitter = true;
     $force_login = false;
     // Make sure we make this request w/o tokens, overwrite the default values in case of login.
     Tweet::reconfig(['token' => '', 'secret' => '']);
     $token = Tweet::getRequestToken(route('twitter.callback'));
     if (isset($token['oauth_token_secret'])) {
         $url = Tweet::getAuthorizeURL($token, $sign_in_twitter, $force_login);
         session()->put('oauth_state', 'start');
         session()->put('oauth_request_token', $token['oauth_token']);
         session()->put('oauth_request_token_secret', $token['oauth_token_secret']);
         return redirect($url);
     }
     return redirect()->route('twitter.error');
 }
Exemplo n.º 2
0
});
Route::post('sendtweet', function () {
    $file = file_get_contents(Input::get('image'));
    $file = base64_encode($file);
    $uploaded_media = Twitter::uploadMedia(['media_data' => $file]);
    return Twitter::postTweet(['status' => Input::get('text'), 'media_ids' => $uploaded_media->media_id_string]);
});
Route::get('twitter/login', ['as' => 'twitter.login', function () {
    // your SIGN IN WITH TWITTER  button should point to this route
    $sign_in_twitter = true;
    $force_login = false;
    // Make sure we make this request w/o tokens, overwrite the default values in case of login.
    Twitter::reconfig(['token' => '', 'secret' => '']);
    $token = Twitter::getRequestToken(route('twitter.callback'));
    if (isset($token['oauth_token_secret'])) {
        $url = Twitter::getAuthorizeURL($token, $sign_in_twitter, $force_login);
        Session::put('oauth_state', 'start');
        Session::put('oauth_request_token', $token['oauth_token']);
        Session::put('oauth_request_token_secret', $token['oauth_token_secret']);
        return Redirect::to($url);
    }
    return Redirect::route('twitter.error');
}]);
Route::get('twitter/callback', ['as' => '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 = ['token' => Session::get('oauth_request_token'), 'secret' => Session::get('oauth_request_token_secret')];
        Twitter::reconfig($request_token);
        $oauth_verifier = false;
        if (Input::has('oauth_verifier')) {
 public function twitterLogin(AuthenticateUser $authenticateUser, Request $request)
 {
     $sign_in_twitter = true;
     $force_login = true;
     \Twitter::reconfig(['token' => '', 'secret' => '']);
     $token = \Twitter::getRequestToken(route('twitter.callback'));
     if (isset($token['oauth_token_secret'])) {
         $url = \Twitter::getAuthorizeURL($token, $sign_in_twitter, $force_login);
         \Session::put('oauth_state', 'start');
         \Session::put('oauth_request_token', $token['oauth_token']);
         \Session::put('oauth_request_token_secret', $token['oauth_token_secret']);
         return \Redirect::to($url);
     }
     return \Redirect::route('twitter.error');
 }