MENU

[PHP] 玖伍社区定时对接脚本

January 25, 2021 • Read: 321 • 程序源码

具体用途

接口随便抓抓就能出来了,顺手写了个PHP脚本然后每天定时跑就行,比如每天要给QQ名片点一百个赞,空间每天一千人气啥的,就懒得每天去社区里面下单了。

使用方法

随便找个玖伍社区,然后找到感兴趣的商品,点进去之后URL地址栏就能看到商品ID和类型ID,然后自己看情况冲个几块钱或者10块钱,一般像点赞这种充10块钱,每天少花一点一个月是没问题滴;对应下面的分割线里面的配置项全部填好保存好,上传到服务器,有宝塔的找好路径丢到计划任务就行。

效果图

宝塔计划任务.png

执行日志.png

金额明细.png

脚本

<?php
// -----------------------------------
$domain     = 'www.baidu.com';    // 社区域名
$username   = '123234';           // 社区账号
$password   = '123234';           // 社区密码
$goods_id   = '4616';             // 商品ID
$goods_type = '158';              // 类型ID
$num        = '1000';             // 下单数量
$qq         = '123234';           // 下单账号
// -----------------------------------

$url  = "http://{$domain}/index.php?m=home&c=order&a=add";
$post = [
    'Api_UserName'    => $username,
    'Api_UserMd5Pass' => md5($password),
    'goods_id'        => $goods_id,
    'goods_type'      => $goods_type,
    'need_num_0'      => $num,
    'pay_type'        => 1,
    'qq'              => $qq,
];
$data = getCurl($url, ['post' => $post]);
$arr  = json_decode($data, true);

if (isset($arr['info'])) {

    echo "提交结果:{$arr['info']} \n";
}
if (preg_match("/<p\\sclass=\"error\">(.*?)<\\/p>/", $data, $msg)) {

    echo "下单失败:{$msg[1]} \n";
}

function getCurl($url, $opt = [])
{
    $cookie = '';
    if (is_array($opt['cookie'])) {
        foreach ($opt['cookie'] as $k => $v) {
            $cookie .= $k . '=' . $v . '; ';
        }
    }

    $cookie = (mb_substr($cookie, 0, mb_strlen($cookie) - 2));

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_COOKIE, $cookie);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_NOBODY, $opt['nobody']);
    curl_setopt($ch, CURLOPT_HEADER, $opt['header'] ?? false);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $opt['headers'] ?? []);
    curl_setopt($ch, CURLOPT_REFERER, $opt['refer'] ?? 'https://user.qzone.qq.com/');
    curl_setopt($ch, CURLOPT_USERAGENT,
        $opt['UA'] ?? "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36");

    if (isset($opt['post'])) {
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, is_array($opt['post']) ? http_build_query($opt['post']) : $opt['post']);
    }
    if (isset($opt['proxy']) && is_array($opt['proxy'])) {
        curl_setopt($ch, CURLOPT_PROXY, $opt['proxy']['ip']);
        curl_setopt($ch, CURLOPT_PROXYPORT, $opt['proxy']['port']);
    }
    $res   = curl_exec($ch);
    $error = curl_error($ch);
    $code  = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    if ($opt['detail']) {
        return ['code' => $code, 'error' => $error, 'response' => $res,];
    }

    return $res;
}