Beispiel #1
0
<?php

define("IN_KEKE", TRUE);
include '../app_comm.php';
if (!in_array($_REQUEST['state'], array('sina', 'qq', 'taobao', 'renren', 'douban', 'baidu'))) {
    exit('参数错误');
}
if ($_REQUEST['state'] && $_REQUEST['code']) {
    $oauth_obj = OAuthClass::factory($_REQUEST['state']);
    $token = $oauth_obj->getAccessToken($_REQUEST['code']);
    if ($token) {
        $_SESSION['oauth_token'] = $token;
        switch ($_REQUEST['state']) {
            case 'sina':
                $oauth_obj->getAccountUid();
                $oauthInfo = $oauth_obj->getAccountInfo();
                unset($oauth_obj, $_SESSION['oauth_token']);
                $saveInfo = array('account' => intval($oauthInfo['id']), 'nickname' => $oauthInfo['name'], 'gender' => $oauthInfo['gender'] === 'm' ? '男' : '女', 'type' => $_REQUEST['state']);
                break;
            case 'qq':
                $oauth_obj->getOpenid();
                $oauthInfo = $oauth_obj->getAccountInfo();
                unset($oauth_obj, $_SESSION['oauth_token']);
                $saveInfo = array('account' => UserCenter::getUnique($oauthInfo), 'nickname' => $oauthInfo['nickname'], 'gender' => $oauthInfo['gender'], 'type' => $_REQUEST['state']);
                break;
            case 'renren':
                $oauth_obj->getUserId();
                $oauthInfo = $oauth_obj->getAccountInfo();
                unset($oauth_obj, $_SESSION['oauth_token']);
                $saveInfo = array('account' => $oauthInfo['id'], 'nickname' => $oauthInfo['name'], 'gender' => strtoupper($oauthInfo['basicInformation']['sex']) == 'MALE' ? '男' : '女', 'type' => $_REQUEST['state']);
                break;
Beispiel #2
0
<?php

define("IN_KEKE", TRUE);
include '../app_comm.php';
if (in_array($type, array('sina', 'qq', 'taobao', 'renren', 'douban', 'baidu'))) {
    $oauth_obj = OAuthClass::factory($type);
    $oauth_obj->requestAuthorize();
} else {
    exit('type参数错误');
}