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); } }
//return var_dump($session_key); if ($session_key) { $client = new RenRenClient(); $client->setSessionKey($session_key); // 调用api时的第一个参数是api方法名。 // 第二个参数请参考renren.class.php文件中的配置进行设置。 $renren = $client->POST('users.getInfo'); //return var_dump($renren); $renren = $renren[0]; $username = $renren['uid']; $name = $renren['name']; $head = $renren['headurl']; $url = 'http://www.renren.com/profile.do?id=' . $username; $email = $username . '@renren.com'; $tid = "rtid"; $uid = get_user_by_meta_value('renrenid', $username); if (!$uid) { $uid = email_exists($email); } $userinfo = array($tid, $username, $name, $head, $url, $username); if ($uid) { wp_connect_login($userinfo, $email, $uid); } else { wp_connect_login($userinfo, $email); } header('Location:' . $redirect_to); } else { wp_die("获取用户授权信息失败,请重新<a href=" . site_url('wp-login.php', 'login') . ">登录</a> 或者 清除浏览器缓存再试! <a href='{$redirect_to}'>返回</a>"); } } else { wp_die("获取用户授权信息失败,请重新<a href=" . site_url('wp-login.php', 'login') . ">登录</a> 或者 清除浏览器缓存再试! <a href='{$redirect_to}'>返回</a>");
function save_dengluComment($comment, $parent = 0) { global $wpdb; if ($commentID = $comment['sourceID']) { // 以前导入到灯鹭服务器记录的本地评论ID return $commentID; } $cid = $comment['cid']; if ($ret = get_commentID($cid)) { return $ret; } $weiboinfo = get_weiboInfo($comment['mediaID']); $mid = $weiboinfo[0] . 'mid'; $id = $weiboinfo[1]; if (empty($comment['email'])) { if (in_array($comment['mediaID'], array(3, 4, 5, 6, 7, 8, 9, 13, 17, 28))) { if ($comment['url']) { $weibo_uid = str_replace($weiboinfo[3], '', $comment['url']); } elseif ($id = 'qqid') { $path = explode('/', $comment['head']); $weibo_uid = $path[4] . '/' . $path[5]; } $user_id = get_user_by_meta_value($id, $weibo_uid); } $domain = ifab($weiboinfo[2], '@denglu.cc'); $email = $weibo_uid ? $weibo_uid . $domain : $comment['uid'] . $domain; } else { //if ($id = 'facebookid' && $comment['url']) { // $weibo_uid = str_replace($weiboinfo[3], '', $comment['url']); //} $email = $comment['email']; } if (!$user_id) { $user_id = get_user_by_meta_value($mid, $comment['uid']); } $commentdata = array('comment_post_ID' => $comment['postid'], 'comment_author' => $comment['nick'], 'comment_author_email' => $email, 'comment_author_url' => $comment['url'], 'comment_content' => $comment['content'], 'comment_type' => '', 'comment_parent' => $parent, 'user_id' => $user_id ? $user_id : 0, 'comment_author_IP' => $comment['ip'], 'comment_agent' => 'Denglu_' . $cid, 'comment_date' => $comment['date'], 'comment_approved' => dcState($comment['state'])); $commentID = get_commentID($cid); if (!$commentID) { $commentID = wp_insert_comment($commentdata); do_action('save_denglu_comment', $commentID, $comment, $weibo_uid, $user_id); } return $commentID; }
break; case "twitter": $to = new twitterClient(WEIBO_APP_KEY, WEIBO_SECRET, $last_key['oauth_token'], $last_key['oauth_token_secret']); $result = $to->verify_credentials(); $result = json_decode($result, true); $only_id = $username = $at = $result['screen_name']; // $only_id = $result['id_str']; // return var_dump($result); if ($only_id) { $tid = "ttid"; $id = 'twitterid'; $email = $only_id . '@twitter.com'; $name = $at = $result['name']; $url = 'http://twitter.com/' . $only_id; $head = $result['profile_image_url']; $uid = ifab(get_user_by_meta_value($id, $only_id), email_exists($email)); } break; default: } $_SESSION['wp_url_login'] = ""; if (!$only_id) { return var_dump($result); } if (!is_user_logged_in()) { // 登录 $userinfo = array($tid, $username, $name, $head, $url, $only_id, $oauth_token); // return var_dump($userinfo); if ($uid) { wp_connect_login($userinfo, $email, $uid); } else {