本文整理汇总了PHP中TwitterOAuth::accessToken方法的典型用法代码示例。如果您正苦于以下问题:PHP TwitterOAuth::accessToken方法的具体用法?PHP TwitterOAuth::accessToken怎么用?PHP TwitterOAuth::accessToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TwitterOAuth
的用法示例。
在下文中一共展示了TwitterOAuth::accessToken方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switch
function social_login_callback_init()
{
if (isset($_GET['hsl_callback'])) {
// && !is_user_logged_in()){
switch ($_GET['hsl_callback']) {
case 'naver':
if (!class_exists('NaverOAuth')) {
require_once dirname(__FILE__) . '/class.naveroauth.php';
}
@session_start();
//print_r($_SESSION);
$connection = new NaverOAuth($consumer_key, $consumer_secret, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
//print_r($connection);
$access_token = $connection->getAccessToken($_GET['oauth_verifier']);
$user_profile = $connection->get_user_profile();
if (isset($user_profile['userID'])) {
$this->login($user_profile['userID'], $user_profile['user_email'], $user_profile['nickname'], $user_profile['profImg'], $_GET['hsl_callback']);
}
die;
break;
case 'kakao':
if (!class_exists('kakaoOAuth')) {
require_once dirname(__FILE__) . '/class.kakaooauth.php';
}
$code = $_GET['code'];
$connection = new KakaoOAuth($consumer_key, $code);
$access_token = $connection->getAccessToken();
$user_profile = $connection->get_user_profile($access_token);
if (isset($user_profile['userID'])) {
$this->login($user_profile['userID'], $user_profile['user_email'], $user_profile['nickname'], $user_profile['profImg'], $_GET['hsl_callback']);
}
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']));
$access_token = $facebook->getAccessToken();
$facebook->setAccessToken($access_token);
//$facebook->setExtendedAccessToken();echo 'asdf';
$access_token = $facebook->getAccessToken();
if ($access_token) {
$facebook->setAccessToken($access_token);
}
$facebook->setAccessToken($access_token);
$data = $facebook->api('/me');
$user_profile = array('userID' => $data['id'], 'user_email' => 'f-' . $data['email'], 'nickname' => $data['name'], 'profImg' => "https://graph.facebook.com/" . $data['id'] . "/picture?width=150&height=150", 'first_name' => $data['first_name'], 'last_name' => $data['last_name']);
if (isset($user_profile['userID'])) {
$this->login($user_profile['userID'], $user_profile['user_email'], $user_profile['nickname'], $user_profile['profImg'], $_GET['hsl_callback'], $user_profile['first_name'], $user_profile['last_name']);
}
die;
break;
case 'twitter':
if (!class_exists('TwitterOAuth')) {
require_once dirname(__FILE__) . '/class.twitteroauth.php';
}
@session_start();
if (isset($_REQUEST['oauth_verifier'])) {
$twitter = new TwitterOAuth($consumer_key, $consumer_secret, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
$access_token = $twitter->accessToken($_GET['oauth_verifier']);
$response = $twitter->get('account/verify_credentials.json');
$user_profile = array('userID' => $response->id, 'user_email' => 't-' . $response->screen_name . '@temp.com', 'nickname' => $response->name, 'profImg' => $response->profile_image_url);
if (isset($user_profile['userID'])) {
$this->login($user_profile['userID'], $user_profile['user_email'], $user_profile['nickname'], $user_profile['profImg'], $_GET['hsl_callback']);
}
}
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'));
$code = array_key_exists('code', $_REQUEST) ? $_REQUEST['code'] : "";
$google->authenticate($code);
$response = $google->api("https://www.googleapis.com/plus/v1/people/me");
$user_profile = array('userID' => $response->id, 'user_email' => 'g-' . $response->emails[0]->value, 'nickname' => property_exists($response, 'displayName') ? $response->displayName : "", 'profImg' => property_exists($response, 'image') ? property_exists($response->image, 'url') ? substr($response->image->url, 0, -2) . "200" : '' : '', 'first_name' => $response->name->givenName, 'last_name' => $response->name->familyName);
if (isset($user_profile['userID'])) {
$this->login($user_profile['userID'], $user_profile['user_email'], $user_profile['nickname'], $user_profile['profImg'], $_GET['hsl_callback'], $user_profile['first_name'], $user_profile['last_name']);
}
die;
break;
}
}
}