function wp_update_t_sina($tok, $status, $value)
{
    if (!class_exists('sinaOAuth')) {
        include dirname(__FILE__) . '/OAuth/sina_OAuth.php';
    }
    $to = new sinaClient(SINA_APP_KEY, SINA_APP_SECRET, $tok['oauth_token'], $tok['oauth_token_secret']);
    $result = $to->update($status, $value);
    return $result;
}
function wp_connect_comment($id)
{
    global $siteurl, $post, $wptm_options, $wptm_connect, $wptm_advanced;
    $post_id = $_POST['comment_post_ID'] ? $_POST['comment_post_ID'] : $post->ID;
    if (!$post_id) {
        return;
    }
    @ini_set("max_execution_time", 60);
    $comments = get_comment($id);
    $user_id = $comments->user_id;
    $comment_content = wp_replace($comments->comment_content);
    $parent_id = $comments->comment_parent;
    if ($user_id) {
        if ($parent_id) {
            $comment_parent = get_comment($parent_id);
            $parent_uid = $comment_parent->user_id;
            $name = get_user_meta($parent_uid, 'login_name', true);
        }
        $tid = $_POST['sync_comment'];
        if ($tid) {
            if (!is_object($post)) {
                $post = get_post($post_id);
            }
            $url = get_permalink($post_id) . '#comment-' . $id;
            if ($wptm_options['t_cn']) {
                $url = get_t_cn(urlencode($url));
            }
            $title = wp_replace($post->post_title);
            $username = get_user_meta($user_id, 'login_name', true);
            require_once dirname(__FILE__) . '/OAuth/OAuth.php';
            if ($tid == 'stid') {
                $login = get_user_meta($user_id, 'login_sina', true);
                if ($login[0] && $login[1]) {
                    if (!class_exists('sinaOAuth')) {
                        include dirname(__FILE__) . '/OAuth/sina_OAuth.php';
                    }
                    $to = new sinaClient(SINA_APP_KEY, SINA_APP_SECRET, $login[0], $login[1]);
                    $content = at_username($name['sina'], $username['sina'], $wptm_connect['sina_username'], $comment_content);
                    //return var_dump($content);
                    $status = wp_status('评论《' . $title . '》: ' . $content, urlencode($url), 140, 1);
                    $result = $to->update($status);
                }
            } elseif ($tid == 'qtid') {
                $login = get_user_meta($user_id, 'login_qq', true);
                if ($login[0] && $login[1]) {
                    if (!class_exists('qqOAuth')) {
                        include dirname(__FILE__) . '/OAuth/qq_OAuth.php';
                    }
                    $to = new qqClient(QQ_APP_KEY, QQ_APP_SECRET, $login[0], $login[1]);
                    $content = at_username($name['qq'], $username['qq'], $wptm_connect['qq_username'], $comment_content);
                    $status = wp_status('评论《' . $title . '》: ' . $content, $url, 140, 1);
                    $result = $to->update($status);
                }
            } elseif ($tid == 'ntid') {
                $login = get_user_meta($user_id, 'login_netease', true);
                if ($login[0] && $login[1]) {
                    if (!class_exists('neteaseOAuth')) {
                        include dirname(__FILE__) . '/OAuth/netease_OAuth.php';
                    }
                    $to = new neteaseClient(APP_KEY, APP_SECRET, $login[0], $login[1]);
                    $content = at_username($name['netease'], $username['netease'], $wptm_connect['netease_username'], $comment_content);
                    $status = wp_status('评论《' . $title . '》: ' . $content, $url, 163);
                    $result = $to->update($status);
                }
            } elseif ($tid == 'shtid') {
                $login = get_user_meta($user_id, 'login_sohu', true);
                if ($login[0] && $login[1]) {
                    if (!class_exists('sohuOAuth')) {
                        include dirname(__FILE__) . '/OAuth/sohu_OAuth.php';
                    }
                    $to = new sohuClient(SOHU_APP_KEY, SOHU_APP_SECRET, $login[0], $login[1]);
                    $content = at_username($name['sohu'], $username['sohu'], $wptm_connect['sohu_username'], $comment_content);
                    $status = wp_status('评论《' . $title . '》: ' . $content, urlencode($url), 140, 1);
                    $result = $to->update($status);
                }
            } elseif ($tid == 'dtid') {
                if ($login = get_user_meta($user_id, 'login_douban', true)) {
                    if ($login[0] && $login[1]) {
                        if (!class_exists('doubanOAuth')) {
                            include dirname(__FILE__) . '/OAuth/douban_OAuth.php';
                        }
                        $to = new doubanClient(DOUBAN_APP_KEY, DOUBAN_APP_SECRET, $login[0], $login[1]);
                        $status = wp_status('评论《' . $title . '》: ' . $comment_content, $url, 128);
                        $result = $to->update($status);
                    }
                }
            }
        }
    }
}
Example #3
0
function wp_repost_t_sina($tok, $sid, $text)
{
    if ($tok['oauth_token']) {
        class_exists('sinaOAuth') or (require dirname(__FILE__) . "/OAuth/sina_OAuth.php");
        $to = new sinaClient(SINA_APP_KEY, SINA_APP_SECRET, $tok['oauth_token'], $tok['oauth_token_secret']);
        $result = $to->repost($sid, $text);
    } elseif ($tok['access_token']) {
        // V2.0
        class_exists('OAuthV2') or (require dirname(__FILE__) . "/OAuth/OAuthV2.php");
        class_exists('sinaClientV2') or (require dirname(__FILE__) . "/OAuth/sina_OAuthV2.php");
        $to = new sinaClientV2(SINA_APP_KEY, SINA_APP_SECRET, $tok['access_token']);
        $result = $to->repost($sid, $text);
    }
    return $result;
}