|
本帖最后由 Eric.c 于 2017-7-3 12:11 编辑
看到还是有人老是关注7o 1t 版本,没事按下f5.... 所以给大家撸了一个代码玩玩。。。
已在4台服务器上测试过了。 能帮到也就酱紫了。。。
github: https://github.com/jekyllcao/online.net
确保是linux服务器,已经安装了php
将下面的代码给保存成一个php文件(如文件名a.php),然后设置crontab 的任务。
crontab -e 回车
按 i ,然后输入 */1 * * * * php的执行路径 a.php的绝对路径
按esc ,再输入:wq 退出。
ps: 如果你php安装的是lnmp套件(lnmp.org),那么php的执行路径是 : /usr/bin/php,
如果你不确定,直接输入which php, 会有返回值
- <?php
- //=========================================Config info====================================================
- $offerid = "728"; // 728: 7欧1t , 774: 7欧ssd
- $title = "Online 有货了!"; //微信通知标题
- $desp = "Online 有货了!"; //微信通知内容
- $key = 'SCU6641T52d189fd61c651c03ba188a41a2280a558c8155xxx'; //方糖的微信通知的key,自己登录“http://sc.ftqq.com”申请
- //=========================================main selection====================================================
- $cmd ="curl 'https://console.online.net/en/order/server_limited' -H 'Pragma: no-cache' -H 'Origin: https://www.online.net' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4,zh-TW;q=0.2,ja;q=0.2,fr;q=0.2' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Cache-Control: no-cache' -H 'Referer: https://www.online.net/en/summer-2017/sales' -H 'Cookie: PHPSESSID-1=s602745rfibh2929tf6jh5o251; SERVERID=web-dc2; _pk_ref.2.3d3d=%5B%22%22%2C%22%22%2C1498936258%2C%22https%3A%2F%2Fwww.online.net%2Fen%2Fsummer-2017%2Fsales%22%5D; _pk_id.2.3d3d=20af576204479f2c.1491289136.47.1498936272.1498936258.; _gat_onlineTracker=1; _ga=GA1.2.1668319752.1490860501; _gid=GA1.2.1443765524.1498924054' -H 'Connection: keep-alive' --data 'server_offer=$offerid' --compressed";
- $data = shell_exec($cmd);
- if ( strpos($data,"unavailable")) {
- echo "sold out";
- // sc_send ("没货",$desp,$key);
- }
- else
- {
- sc_send ($title,$desp,$key);
- }
- //=========================================function ====================================================
- function sc_send($text, $desp = '', $key ="") {
- $postdata = http_build_query(
- array('text' => $text, 'desp' => $desp));
- $opts = array('http' =>
- array(
- 'method' => 'POST',
- 'header' => 'Content-type: application/x-www-form-urlencoded',
- 'content' => $postdata
- )
- );
- $context = stream_context_create($opts);
- return $result = file_get_contents('http://sc.ftqq.com/'.$key.'.send', false, $context);
- }
复制代码
====FAQ:=====
1/ 不要直接在服务器上用vim修改,因为vim对中文的支持。。。。 所以还是在你本地上存文件后再上传吧
2/ 上传后,手动执行一遍 php a.php , 看看是否有报错。
3/ 如果报错,一般是php.ini中的disable_function函数禁止了,编辑这个文件,直接注释掉这行后重启 lnmp 或者php-fpm 即可
4/ 代码无技术支持。。。 别找我。。。 也别让我写自动登录和提交(看懂代码的自己扩展,so easy,需要花时间而已)。。。。
新增一个脚本,没做完整的可行性测试,仅在上面的代码上增加邮件通知,有需要的自己搞,要测试过的,不要看这部分。。。。。直接用上面的。。。====================
- <?php
- //=========================================HOW TO USE IT ====================================================
- /*
- 1/ save the code into a file with "ANY.php" as name
- 2/ config the setting as bellow,
- 3/ pls run one time to check the health of the script . the problem is easy to fix . just do it by youself.
- 4/ create a cron rule like " * * * * * /path/to/php /path/to/your/script "
- */
- //=========================================Config info====================================================
- $offerid = "645"; // 728: 7欧1t , 774: 7欧ssd
- $title = "Online can be order now !"; //Notify subject
- $desp = "Online content ......!"; //Notify Content
- //Which notify method you want to use , 1: wechat; 0:Email
- $type = 1;
- // For mail notify method , We use local mail as sent method , So pls make sure the sendmail has been installed on your server.
- $to ="[email protected]"; //Mail Receiver
- // For Wechat Notify method ,
- $key = 'SCU6641T52d189fd61c651c03ba188a41a2280a558c8155d8c56e'; //方糖的微信通知的key,自己登录“http://sc.ftqq.com”申请
- //=========================================main selection====================================================
- $cmd ="curl 'https://console.online.net/en/order/server_limited' -H 'Pragma: no-cache' -H 'Origin: https://www.online.net' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4,zh-TW;q=0.2,ja;q=0.2,fr;q=0.2' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Cache-Control: no-cache' -H 'Referer: https://www.online.net/en/summer-2017/sales' -H 'Cookie: PHPSESSID-1=s602745rfibh2929tf6jh5o251; SERVERID=web-dc2; _pk_ref.2.3d3d=%5B%22%22%2C%22%22%2C1498936258%2C%22https%3A%2F%2Fwww.online.net%2Fen%2Fsummer-2017%2Fsales%22%5D; _pk_id.2.3d3d=20af576204479f2c.1491289136.47.1498936272.1498936258.; _gat_onlineTracker=1; _ga=GA1.2.1668319752.1490860501; _gid=GA1.2.1443765524.1498924054' -H 'Connection: keep-alive' --data 'server_offer=$offerid' --compressed";
- $data = shell_exec($cmd);
- if ( strpos($data,"unavailable")) {
- echo "sold out";
- // sc_send ("没货",$desp,$key);
- }
- else
- {
- if($type)
- {
- sc_send ($title,$desp,$key);
- }
- else
- {
- send($title,$desp,$to);
- }
-
- }
- //=========================================function ====================================================
- function sc_send($text, $desp = '', $key ="") {
- $postdata = http_build_query(
- array('text' => $text, 'desp' => $desp));
- $opts = array('http' =>
- array(
- 'method' => 'POST',
- 'header' => 'Content-type: application/x-www-form-urlencoded',
- 'content' => $postdata
- )
- );
- $context = stream_context_create($opts);
- return $result = file_get_contents('http://sc.ftqq.com/'.$key.'.send', false, $context);
- }
- function sendmail($title,$desp,$to)
- {
- $cmd = "echo "$desp" | mail -s "$title" $to";
- $data = shell_exec($cmd);
- if ( strpos($data,"not sent")) {
- echo "Fail to send ".$data;
- }
- else
- {
- echo "Mail Sent";
- }
- }
复制代码
|
|