本文整理汇总了PHP中TwitterOAuth::requestToken方法的典型用法代码示例。如果您正苦于以下问题:PHP TwitterOAuth::requestToken方法的具体用法?PHP TwitterOAuth::requestToken怎么用?PHP TwitterOAuth::requestToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TwitterOAuth
的用法示例。
在下文中一共展示了TwitterOAuth::requestToken方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switch
function social_login_init()
{
if (isset($_GET['hsl_login'])) {
// && !is_user_logged_in()){
switch ($_GET['hsl_login']) {
case 'naver':
if (!class_exists('NaverOAuth')) {
require_once dirname(__FILE__) . '/class.naveroauth.php';
}
session_start();
$connection = new NaverOAuth($consumer_key, $consumer_secret);
$connection->set_state();
$request_token_info = $connection->getRequestToken($callback_url);
$_SESSION['oauth_token'] = $token = $request_token_info['oauth_token'];
$_SESSION['oauth_token_secret'] = $request_token_info['oauth_token_secret'];
header('Location:' . $connection->authorizeURL() . '&oauth_token=' . $request_token_info['oauth_token']);
//header('Location:'.$connection->authorizeURL().'&client_id='.$consumer_key);
die;
break;
case 'facebook':
if (!class_exists('Facebook')) {
require_once dirname(__FILE__) . '/facebook/facebook.php';
}
$hotpack_social_login = get_option('hotpack_social_login');
$facebook = new Facebook(array('appId' => $hotpack_social_login['facebook']['consumer_key'], 'secret' => $hotpack_social_login['facebook']['consumer_secret']));
$parameters = array('scope' => 'email, public_profile, user_friends', 'redirect_uri' => home_url('?hsl_callback=facebook'), 'display' => 'page');
$loginUrl = $facebook->getLoginUrl($parameters);
header('Location:' . $loginUrl);
die;
break;
case 'twitter':
if (!class_exists('TwitterOAuth')) {
require_once dirname(__FILE__) . '/class.twitteroauth.php';
}
session_start();
$twitter = new TwitterOAuth($consumer_key, $consumer_secret);
$tokens = $twitter->requestToken();
$_SESSION['oauth_token'] = $token = $tokens['oauth_token'];
$_SESSION['oauth_token_secret'] = $tokens['oauth_token_secret'];
header('Location:' . $twitter->authorizeUrl($tokens));
die;
break;
case 'google':
if (!class_exists('GoogleOAuth')) {
require_once dirname(__FILE__) . '/class.googleoauth.php';
}
session_start();
$google = new GoogleOAuth($consumer_key, $consumer_secret, home_url('?hsl_callback=google'));
$parameters = array('scope' => 'profile https://www.googleapis.com/auth/plus.profile.emails.read', 'access_type' => 'offline');
$loginUrl = $google->authorizeUrl($parameters);
header('Location:' . $loginUrl);
die;
break;
}
}
}