function wp_connect_tianya() { if (!class_exists('tianyaOAuth')) { include dirname(__FILE__) . '/OAuth/tianya_OAuth.php'; } $to = new tianyaOAuth(TIANYA_APP_KEY, TIANYA_APP_SECRET, $_GET['oauth_token'], $_SESSION['oauth_token_secret']); $tok = $to->getAccessToken($_REQUEST['oauth_verifier']); $to = new tianyaClient(TIANYA_APP_KEY, TIANYA_APP_SECRET, $tok['oauth_token'], $tok['oauth_token_secret']); $tianya = $to->get_user_info(); if (!is_array($tianya) || $tianya['error_msg']) { return wp_noauth(); } $tianya = $tianya['user']; $username = $tianya['user_id']; $email = $username . '@tianya.cn'; $url = "http://my.tianya.cn/" . $username; $tid = "tytid"; $uid = ifab(get_user_by_meta_value($tid, $username), email_exists($email)); $userinfo = array($tid, $username, $tianya['user_name'], $username, $url, $username, $tok['oauth_token'], $tok['oauth_token_secret']); if ($uid) { wp_connect_login($userinfo, $email, $uid); } else { wp_connect_login($userinfo, $email); } }
$douban_xmlns = $douban->children('http://www.douban.com/xmlns/'); $only_id = str_replace("http://api.douban.com/people/", "", $douban->id); // return var_dump($douban); if ($only_id) { $tid = $id = 'dtid'; $email = $only_id . '@douban.com'; $username = $douban_xmlns->uid; $name = $douban->title; $url = "http://www.douban.com/people/" . $username; $head = $only_id; $uid = ifab(get_user_by_meta_value($id, $only_id), email_exists($email)); } break; case "tianya": $to = new tianyaClient(WEIBO_APP_KEY, WEIBO_SECRET, $last_key['oauth_token'], $last_key['oauth_token_secret']); $result = $to->get_user_info(); $result = $result['user']; $only_id = $username = $result['user_id']; // return var_dump($result); if ($only_id) { $tid = $id = 'tytid'; $email = $only_id . '@tianya.cn'; $name = $at = $result['user_name']; $url = 'http://my.tianya.cn/' . $only_id; $head = $only_id; $uid = ifab(get_user_by_meta_value($id, $only_id), email_exists($email)); } break; case "twitter": $to = new twitterClient(WEIBO_APP_KEY, WEIBO_SECRET, $last_key['oauth_token'], $last_key['oauth_token_secret']); $result = $to->verify_credentials();