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); } }
} elseif ($_GET['OAuth'] == "twitter" || $_GET['OAuth'] == "TWITTER" || $_GET['callback'] == "TWITTER") { include_once "OAuth/twitter_OAuth.php"; $a = new twitterOAuth(T_APP_KEY, T_APP_SECRET); $b = new twitterOAuth(T_APP_KEY, T_APP_SECRET, $_SESSION['keys']['oauth_token'], $_SESSION['keys']['oauth_token_secret']); $tok = "wptm_twitter_oauth"; $tid = "TWITTER"; } elseif ($_GET['OAuth'] == "douban" || $_GET['OAuth'] == "DOUBAN" || $_GET['callback'] == "DOUBAN") { include_once "OAuth/douban_OAuth.php"; $a = new doubanOAuth(DOUBAN_APP_KEY, DOUBAN_APP_SECRET); $b = new doubanOAuth(DOUBAN_APP_KEY, DOUBAN_APP_SECRET, $_SESSION['keys']['oauth_token'], $_SESSION['keys']['oauth_token_secret']); $tok = "wptm_douban"; $tid = "DOUBAN"; } elseif ($_GET['OAuth'] == "tianya" || $_GET['OAuth'] == "TIANYA" || $_GET['callback'] == "TIANYA") { include_once "OAuth/tianya_OAuth.php"; $a = new tianyaOAuth(TIANYA_APP_KEY, TIANYA_APP_SECRET); $b = new tianyaOAuth(TIANYA_APP_KEY, TIANYA_APP_SECRET, $_SESSION['keys']['oauth_token'], $_SESSION['keys']['oauth_token_secret']); $tok = "wptm_tianya"; $tid = "TIANYA"; } else { return false; } if ($_GET['OAuth']) { $callback = get_bloginfo('wpurl') . '/wp-content/plugins/wp-connect/go.php?callback=' . $tid; $keys = $a->getRequestToken($callback); $aurl = $a->getAuthorizeURL($keys['oauth_token'], false, $callback); $_SESSION['keys'] = $keys; if (!$_SESSION['wp_url_bind']) { $aurl = get_bloginfo('url'); } header('Location:' . $aurl); } elseif ($_GET['callback']) {