<?php
function http_request($url, $post = '',$header=array(), $timeout = 30)
// 发起网络请求
{
if (empty($url)) {
return false;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
if($header==true){
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
}
if ($post != '' && !empty($post)) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
$redis = new \Redis();
$redis->connect('127.0.0.1');
$cookie = $redis->get('juejinCookie');
$url = "https://api.juejin.cn/growth_api/v1/check_in?aid=2608&uuid=6942769092361864700&_signature=_02B4Z6wo00101OfjvVgAAIDAZ-FHG2A-u0zn57nAAFic4KcjyX0P1Ckl1w.GdtOV4WOQLBkWpIdFuJcU7GqVv308qaVNOkj94pg34KgR0Qgt993GS2pV0qn59NRNHJwBY8F9yhimMaklRpm1e5";
$header = [':authority: api.juejin.cn'];
$header[] = ':method: POST';
$header[] = ':path: /growth_api/v1/check_in?aid=2608&uuid=6942769092361864708&_signature=_02B4Z6wo00101OfjvVgAAIDAZ-FHG2A-u0zn57nAAFic4KcjyX0P1Ckl1w.GdtOV4WOQLBkWpIdFuJcU7GqVv308qaVNOkj94pg34KgR0Qgt993GS2pV0qn59NRNHJwBY8F9yhimMaklRpm1e5';
$header[] = ':scheme: https';
$header[] = 'accept: */*';
$header[] = 'accept-encoding: gzip, deflate, br';
$header[] = 'accept-language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,pt;q=0.5';
$header[] = 'content-length: 2';
$header[] = 'content-type: application/json';
$header[] = 'cookie: '.$cookie;
$header[] = 'origin: https://juejin.cn';
$header[] = 'referer: https://juejin.cn/';
$header[] = 'sec-ch-ua: "Chromium";v="94", "Microsoft Edge";v="94", ";Not A Brand";v="99"';
$header[] = 'sec-ch-ua-mobile: ?0';
$header[] = 'sec-ch-ua-platform: "Windows"';
$header[] = 'sec-fetch-dest: empty';
$header[] = 'sec-fetch-mode: cors';
$header[] = 'sec-fetch-site: same-site';
$header[] = 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36 Edg/94.0.992.38';
$res = http_request($url,['time'=>'this'],$header);
$obj = json_decode($res);
if(!isset($obj->err_no) || $obj->err_no > 0) {
$msg = $obj->err_msg ?? '';
exec("sendEmail -f 666@163.com -t 888@qq.com -s smtp.163.com -u \"掘金签到失败\" -o message-content-type=html -o message-charset=utf8 -xu 666@163.com -xp 你的邮箱授权码 -m ".$msg);
}
// 666是发件人,888是收件人。
服务器端先安装php + redis + sendEmail
redis先写入juejinCookie, 过期时可以替换。
linux终端执行命令:php? ?上面的脚本.php
没报错就是成功了。
|