本文整理匯總了PHP中Twitter::getAuthorizeURL方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twitter::getAuthorizeURL方法的具體用法?PHP Twitter::getAuthorizeURL怎麽用?PHP Twitter::getAuthorizeURL使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Twitter
的用法示例。
在下文中一共展示了Twitter::getAuthorizeURL方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: login
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');
}
示例2: function
});
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')) {
示例3: twitterLogin
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');
}