Esempio n. 1
0
/**
 * 同步列表
 * @since 2.4.5
 */
function wp_update_list($text, $url, $pic, $account, $post_id = '')
{
    global $wptm_options;
    if (is_array($pic)) {
        // 兼容旧版本
        if ($pic[0] == 'image') {
            $pic = array($pic[1], '', '');
        } elseif ($pic[0] == 'video') {
            $pic = array('', $pic[1], '');
        } elseif ($pic[0] == 'music') {
            $pic = array('', '', $pic[1]);
        }
        if ($pic[0]) {
            // 图片
            $picture = array('image', $pic[0]);
        }
        if ($pic[1] && $pic[1] != $url) {
            // 视频
            $vurl = $pic[1];
        } elseif (is_array($pic[2])) {
            // 音乐
            if ($pic[2][1] && $pic[2][2]) {
                $vurl = '#' . $pic[2][0] . '#' . $pic[2][1] . ' ' . $pic[2][2];
                // #歌手# 歌曲 url
            } else {
                $vurl = $pic[2][0];
                // url
            }
        }
    }
    // 是否使用短网址
    if ($wptm_options['t_cn']) {
        $url = get_url_short($url);
    }
    // 处理完毕输出链接
    $postlink = trim($vurl . ' ' . $url);
    // 截取字数
    $status = wp_status($text, '', 140, 1);
    //灯鹭
    $status1 = wp_status($text, $postlink, 140);
    //网易/人人/饭否/做啥
    $status2 = wp_status($text, urlencode($postlink), 140, 1);
    //新浪/天涯
    $status3 = wp_status($text, $postlink, 140, 1);
    //腾讯/开心
    // return var_dump($status3);
    // 开始同步
    require_once dirname(__FILE__) . '/OAuth/OAuth.php';
    $output = array();
    if ($account['sina']['mediaUserID']) {
        wp_update_share($account['sina']['mediaUserID'], $status, $url, '', $pic[0], $pic[1], $post_id);
    } elseif ($account['sina']) {
        // 新浪微博 /140*
        $ms = wp_update_t_sina($account['sina'], $status2, $picture);
        $output['sina'] = $ms['mid'];
    }
    $mediaUserID = '';
    if ($account['qq']['oauth_token']) {
        // 腾讯微博 /140*
        $output['qq'] = wp_update_t_qq($account['qq'], $status3, $pic);
    } elseif ($account['qq']['mediaUserID']) {
        $mediaUserID .= $account['qq']['mediaUserID'] . ',';
    }
    if ($account['shuoshuo']) {
        // 说说 /140
        wp_post_shuoshuo($account['shuoshuo'], $status2, $pic);
    }
    if ($account['sohu']['oauth_token']) {
        // 搜狐微博 /+
        wp_update_t_sohu($account['sohu'], wp_status($text, $postlink, 200, 1), $picture);
    } elseif ($account['sohu']['mediaUserID']) {
        $mediaUserID .= $account['sohu']['mediaUserID'] . ',';
    }
    if ($account['netease']['oauth_token']) {
        // 网易微博 /163
        wp_update_t_163($account['netease'], $status1, $picture);
    } elseif ($account['netease']['mediaUserID']) {
        $mediaUserID .= $account['netease']['mediaUserID'] . ',';
    }
    if ($account['renren']['mediaUserID']) {
        $mediaUserID .= $account['renren']['mediaUserID'] . ',';
    } elseif ($account['renren']) {
        // 人人网 /140
        wp_update_renren($account['renren'], $status1);
    }
    if ($account['tianya']['oauth_token']) {
        // 天涯 /140*
        wp_update_tianya($account['tianya'], $status2, $picture);
    } elseif ($account['tianya']['mediaUserID']) {
        $mediaUserID .= $account['tianya']['mediaUserID'];
    }
    if ($mediaUserID) {
        wp_update_share(rtrim($mediaUserID, ','), $status, $url, '', $pic[0], $pic[1], $post_id);
    }
    if ($account['wbto']) {
        // 微博通 /140+
        wp_update_wbto($account['wbto'], wp_status($text, $postlink, 140, 1), $picture);
    }
    if ($account['douban']) {
        // 豆瓣 /128
        wp_update_douban($account['douban'], wp_status($text, $postlink, 128));
    }
    if ($account['twitter']) {
        // twitter /140
        wp_update_twitter($account['twitter'], wp_status($text, wp_urlencode($postlink), 140));
    }
    if ($account['kaixin001']) {
        // 开心网 /140+
        wp_update_kaixin001($account['kaixin001'], $status3, $picture);
    }
    /*
    if ($account['digu']) { // 嘀咕 /140
    	wp_update_digu($account['digu'], wp_status($text, urlencode($postlink), 140));
    } 
    if ($account['fanfou']) { // 饭否 /140
    	wp_update_fanfou($account['fanfou'], $status1);
    } 
    if ($account['renjian']) { // 人间 /+
    	wp_update_renjian($account['renjian'], wp_status($text, urlencode($postlink), 200, 1), $picture);
    } 
    if ($account['zuosa']) { // 做啥 /140
    	wp_update_zuosa($account['zuosa'], $status1);
    } 
    */
    // 钩子,方便自定义插件
    do_action('wp_update_list_update', $output, $ms, $post_id);
    return $output;
}
Esempio n. 2
0
function wp_connect_comment($id)
{
    global $post, $wptm_options, $wptm_connect;
    $post_id = isset($_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_url_short($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]) {
                    $token = array('access_token' => $login[0], 'expires_in' => $login[1]);
                    // V2.0
                    $content = at_username($name['sina'], $username['sina'], $wptm_connect['sina_username'], $comment_content);
                    // return var_dump($content);
                    $status = wp_status($content, urlencode($url), 140, 1);
                    $result = wp_update_t_sina($token, $status, '');
                }
            } elseif ($tid == 'qtid') {
                $login = get_user_meta($user_id, 'login_qq', true);
                if ($login[0] && $login[1]) {
                    $token = array('oauth_token' => $login[0], 'oauth_token_secret' => $login[1]);
                    $content = at_username($name['qq'], $username['qq'], $wptm_connect['qq_username'], $comment_content);
                    $status = wp_status($content, $url, 140, 1);
                    $result = wp_update_t_qq($token, $status, '');
                }
            } elseif ($tid == 'ntid') {
                $login = get_user_meta($user_id, 'login_netease', true);
                if ($login[0] && $login[1]) {
                    $token = array('oauth_token' => $login[0], 'oauth_token_secret' => $login[1]);
                    $content = at_username($name['netease'], $username['netease'], $wptm_connect['netease_username'], $comment_content);
                    $status = wp_status($content, $url, 163);
                    $result = wp_update_t_163($token, $status, '');
                }
            } elseif ($tid == 'shtid') {
                $login = get_user_meta($user_id, 'login_sohu', true);
                if ($login[0] && $login[1]) {
                    $token = array('oauth_token' => $login[0], 'oauth_token_secret' => $login[1]);
                    $content = at_username($name['sohu'], $username['sohu'], $wptm_connect['sohu_username'], $comment_content);
                    $status = wp_status($content, $url, 200, 1);
                    $result = wp_update_t_sohu($token, $status, '');
                }
            } elseif ($tid == 'dtid') {
                if ($login = get_user_meta($user_id, 'login_douban', true)) {
                    if ($login[0] && $login[1]) {
                        $token = array('oauth_token' => $login[0], 'oauth_token_secret' => $login[1]);
                        $status = wp_status($comment_content, $url, 128);
                        $result = wp_update_douban($token, $status);
                    }
                }
            }
        }
    }
}
Esempio n. 3
0
function wp_connect_comment($id)
{
    global $post, $wptm_options, $wptm_connect;
    $post_id = isset($_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_url_short($url);
            }
            // $title = wp_replace($post -> post_title);
            $username = get_user_meta($user_id, 'login_name', true);
            if ($tid == 'stid') {
                if ($mediaUserID = get_user_meta($user_id, 'smid', true)) {
                    $content = at_username($name['sina'], $username['sina'], $wptm_connect['sina_username'], $comment_content);
                    wp_update_share($mediaUserID, $content, $url);
                }
            } elseif ($tid == 'qtid') {
                if ($mediaUserID = get_user_meta($user_id, 'qmid', true)) {
                    $content = at_username($name['qq'], $username['qq'], $wptm_connect['qq_username'], $comment_content);
                    wp_update_share($mediaUserID, $content, $url);
                }
            } elseif ($tid == 'ntid') {
                if ($mediaUserID = get_user_meta($user_id, 'nmid', true)) {
                    $content = at_username($name['netease'], $username['netease'], $wptm_connect['netease_username'], $comment_content);
                    wp_update_share($mediaUserID, $content, $url);
                }
            } elseif ($tid == 'shtid') {
                if ($mediaUserID = get_user_meta($user_id, 'shmid', true)) {
                    $content = at_username($name['sohu'], $username['sohu'], $wptm_connect['sohu_username'], $comment_content);
                    wp_update_share($mediaUserID, $content, $url);
                }
            } elseif ($tid == 'tytid') {
                if ($mediaUserID = get_user_meta($user_id, 'tymid', true)) {
                    $content = $comment_content;
                    wp_update_share($mediaUserID, $content, $url);
                }
            }
        }
    }
}