function wp_connect_twitter() { if (!class_exists('twitterOAuth')) { include dirname(__FILE__) . '/OAuth/twitter_OAuth.php'; } $to = new twitterOAuth(T_APP_KEY, T_APP_SECRET, $_GET['oauth_token'], $_SESSION['oauth_token_secret']); $tok = $to->getAccessToken($_REQUEST['oauth_verifier']); $to = new twitterOAuth(T_APP_KEY, T_APP_SECRET, $tok['oauth_token'], $tok['oauth_token_secret']); $twitter = $to->OAuthRequest('http://api.twitter.com/1/account/verify_credentials.json', 'GET', array()); if ($twitter == "no auth") { return wp_noauth(); } $twitter = json_decode($twitter); $username = $sina->screen_name; $email = $username . '@twitter.com'; $tid = "ttid"; $uid = ifab(get_user_by_meta_value('twitterid', $username), email_exists($email)); $userinfo = array($tid, $username, $twitter->name, $twitter->profile_image_url, $twitter->url, $username, $tok['oauth_token'], $tok['oauth_token_secret']); if ($uid) { wp_connect_login($userinfo, $email, $uid); } else { wp_connect_login($userinfo, $email); } }