Example #1
0
 function x_tdou_get($gift_key, $type, $uid)
 {
     if ($type == 1) {
         $type = 'time';
     } elseif ($type == 2) {
         $type = 'rand';
     }
     $formdata = array('ie' => 'utf-8', 'type' => $type, 'tbs' => get_tbs($uid), 'gift_key' => $gift_key);
     $ch = curl_init('http://tieba.baidu.com/tbscore/opengift');
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($formdata));
     curl_setopt($ch, CURLOPT_COOKIE, get_cookie($uid));
     $re = curl_exec($ch);
     curl_close($ch);
     $re = json_decode($re, true);
     return $re;
 }
Example #2
0
function client_sign($uid, $tieba)
{
    $cookie = get_cookie($uid);
    preg_match('/BDUSS=([^ ;]+);/i', $cookie, $matches);
    $BDUSS = trim($matches[1]);
    if (!$BDUSS) {
        return array(-1, '找不到 BDUSS Cookie', 0);
    }
    $ch = curl_init('http://c.tieba.baidu.com/c/c/forum/sign');
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_COOKIE, get_cookie($uid));
    curl_setopt($ch, CURLOPT_POST, 1);
    $array = array('BDUSS' => $BDUSS, '_client_id' => '03-00-DA-59-05-00-72-96-06-00-01-00-04-00-4C-43-01-00-34-F4-02-00-BC-25-09-00-4E-36', '_client_type' => '4', '_client_version' => '1.2.1.17', '_phone_imei' => '540b43b59d21b7a4824e1fd31b08e9a6', 'fid' => $tieba['fid'], 'kw' => urldecode($tieba['unicode_name']), 'net_type' => '3', 'tbs' => get_tbs($uid));
    $sign_str = '';
    foreach ($array as $k => $v) {
        $sign_str .= $k . '=' . $v;
    }
    $sign = strtoupper(md5($sign_str . 'tiebaclient!!!'));
    $array['sign'] = $sign;
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array));
    $sign_json = curl_exec($ch);
    curl_close($ch);
    $res = @json_decode($sign_json, true);
    if (!$res) {
        return array(1, 'JSON 解析错误', 0);
    }
    if ($res['user_info']) {
        $exp = $res['user_info']['sign_bonus_point'];
        return array(2, "签到成功,经验值上升 {$exp}", $exp);
    } else {
        switch ($res['error_code']) {
            case '160002':
                // 已经签过
                return array(2, $res['error_msg'], 0);
            case '1':
                // 未登录
                return array(-1, "ERROR-{$res[error_code]}: " . $res['error_msg'] . ' (Cookie 过期或不正确)', 0);
            case '160004':
                // 不支持
                return array(-1, "ERROR-{$res[error_code]}: " . $res['error_msg'], 0);
            case '160003':
                // 零点 稍后再试
            // 零点 稍后再试
            case '160008':
                // 太快了
                return array(1, "ERROR-{$res[error_code]}: " . $res['error_msg'], 0);
            default:
                return array(1, "ERROR-{$res[error_code]}: " . $res['error_msg'], 0);
        }
    }
}
Example #3
0
 function blockid($fid, $id, $day, $douid)
 {
     $blockid_api = "http://tieba.baidu.com/pmc/blockid";
     $formdata = array('user_name[]' => $id, 'day' => $day, 'fid' => $fid, 'tbs' => get_tbs($douid), 'ie' => 'gbk', 'reason' => "抱歉,你的发贴操作或发表贴子的内容违反了本吧的吧规,已经被封禁,封禁期间不能在本吧继续发言。");
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $blockid_api);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_COOKIE, get_cookie($douid));
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
     curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($formdata));
     $re = @json_decode(curl_exec($ch), true);
     curl_close($ch);
     if (empty($re)) {
         return array('errno' => -1, 'errmsg' => '未知错误!');
     } else {
         return $re;
     }
 }
Example #4
0
function client_rppost($uid, $tieba, $content)
{
    $cookie = get_cookie($uid);
    preg_match('/BDUSS=([^ ;]+);/i', $cookie, $matches);
    $BDUSS = trim($matches[1]);
    $setting = DB::fetch_first("SELECT * FROM xxx_post_setting WHERE uid='{$uid}'");
    if ($setting['client_type'] == 5) {
        $setting['client_type'] = rand(1, 4);
    }
    if (!$BDUSS) {
        return array(-1, '找不到 BDUSS Cookie');
    }
    if (!$content) {
        $content = get_random_content();
    }
    if (!$tieba['tid']) {
        $tieba['tid'] = get_random_tid($tieba['name']);
    }
    $formdata = array('BDUSS' => $BDUSS, '_client_id' => 'wappc_136' . random(10, true) . '_' . random(3, true), '_client_type' => $setting['client_type'], '_client_version' => '5.0.0', '_phone_imei' => md5(random(16)), 'anonymous' => 0, 'content' => $content, 'fid' => $tieba['fid'], 'kw' => urldecode($tieba['name']), 'net_type' => 3, 'tbs' => get_tbs($tieba['uid']), 'tid' => $tieba['tid'], 'title' => "");
    $adddata = '';
    foreach ($formdata as $k => $v) {
        $adddata .= $k . '=' . $v;
    }
    $sign = strtoupper(md5($adddata . 'tiebaclient!!!'));
    $formdata['sign'] = $sign;
    $ch = curl_init('http://c.tieba.baidu.com/c/c/post/add');
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_COOKIE, $cookie);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($formdata));
    $re = @json_decode(curl_exec($ch), ture);
    curl_close($ch);
    switch ($setting['client_type']) {
        case '1':
            $client_res = "iphone";
            break;
        case '2':
            $client_res = "android";
            break;
        case '3':
            $client_res = "WindowsPhone";
            break;
        case '4':
            $client_res = "Windows8";
            break;
    }
    if (!$re) {
        return array(0, 'JSON 解析错误');
    }
    if ($re['error_code'] == 0) {
        return array(2, "使用" . $client_res . '客户端发帖成功,<a href="http://tieba.baidu.com/p/' . $tieba['tid'] . '" target="_blank">查看帖子</a>');
    } else {
        if ($re['error_code'] == 5) {
            return array(5, "需要输入验证码,请检查你是否已经关注该贴吧。");
        } else {
            if ($re['error_code'] == 7) {
                return array(7, "您的操作太频繁了!");
            } else {
                if ($re['error_code'] == 8) {
                    return array(8, "您已经被封禁");
                } else {
                    return array($re['error_code'], "未知错误,错误代码:" . $re['error_code']);
                }
            }
        }
    }
}
Example #5
0
function _client_sign($uid, $tieba)
{
    $cookie = get_cookie($uid);
    preg_match('/BDUSS=([^ ;]+);/i', $cookie, $matches);
    $BDUSS = trim($matches[1]);
    if (!$BDUSS) {
        return array(-1, '找不到 BDUSS Cookie', 0);
    }
    $ch = curl_init('http://c.tieba.baidu.com/c/c/forum/sign');
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded', 'User-Agent: BaiduTieba for Android 5.1.3', 'client_user_token: ' . random(6, true)));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, 1);
    $array = array('BDUSS' => $BDUSS, '_client_id' => 'wappc_138' . random(10, true) . '_' . random(3, true), '_client_type' => '2', '_client_version' => '5.1.3', '_phone_imei' => md5(random(16, true)), 'cuid' => strtoupper(md5(random(16))) . '|' . random(15, true), 'fid' => $tieba['fid'], 'from' => 'tieba', 'kw' => urldecode($tieba['unicode_name']), 'model' => 'Aries', 'net_type' => '3', 'stErrorNums' => '0', 'stMethod' => '1', 'stMode' => '1', 'stSize' => random(5, true), 'stTime' => random(4, true), 'stTimesNum' => '0', 'tbs' => get_tbs($uid), 'timestamp' => time() . rand(1000, 9999));
    $sign_str = '';
    foreach ($array as $k => $v) {
        $sign_str .= $k . '=' . $v;
    }
    $sign = strtoupper(md5($sign_str . 'tiebaclient!!!'));
    $array['sign'] = $sign;
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array));
    $sign_json = curl_exec($ch);
    curl_close($ch);
    $res = @json_decode($sign_json, true);
    if (!$res) {
        return array(1, 'JSON 解析错误', 0);
    }
    if ($res['user_info']) {
        $exp = $res['user_info']['sign_bonus_point'];
        return array(2, "签到成功,经验值上升 {$exp}", $exp);
    } else {
        switch ($res['error_code']) {
            case '340010':
                // 已经签过
            // 已经签过
            case '160002':
            case '3':
                return array(2, $res['error_msg'], 0);
            case '1':
                // 未登录
                return array(-1, "ERROR-{$res[error_code]}: " . $res['error_msg'] . ' (Cookie 过期或不正确)', 0);
            case '160004':
                // 不支持
                return array(-1, "ERROR-{$res[error_code]}: " . $res['error_msg'], 0);
            case '160003':
                // 零点 稍后再试
            // 零点 稍后再试
            case '160008':
                // 太快了
                return array(1, "ERROR-{$res[error_code]}: " . $res['error_msg'], 0);
            default:
                return array(1, "ERROR-{$res[error_code]}: " . $res['error_msg'], 0);
        }
    }
}