Last active
May 15, 2016 00:59
-
-
Save stephenjtong/4482853 to your computer and use it in GitHub Desktop.
云盘每日签到脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_log("============\n".date('Y-m-d H:i')."\n", 3, 'logs/yunpan.log'); | |
$cookie = '你的cookie,去掉token'; | |
function get_token($cookie, $url = 'http://c4.yunpan.360.cn/user/login?st=449'){ | |
$ch = curl_init(); | |
curl_setopt_array($ch, array( | |
CURLOPT_COOKIE => $cookie, | |
CURLOPT_HTTPGET => true, | |
CURLOPT_HEADER => true, | |
CURLOPT_URL => $url, | |
//CURLOPT_VERBOSE => 1, | |
CURLOPT_RETURNTRANSFER => 1, | |
)); | |
$result = curl_exec($ch); | |
preg_match('/token=[^;]*;/', $result, $token); | |
$token = array_shift($token); | |
curl_close($ch); | |
return $cookie.';'.$token; | |
} | |
$cookie = get_token($cookie); | |
$params = array('qid'=>'/*你的qid*/', 'method'=>'signin', 'ajax'=>1); | |
$r = _ajax_call('http://c4.yunpan.360.cn/user/signin/', $params, $cookie, 0); | |
$result = print_r($r,true)."\n"; | |
if(preg_match('/\[errno\] => [^0]/', $result)){ | |
send_notify($result); | |
} | |
function send_notify($r){ | |
$contents=array( | |
'title' => '云盘签到错误', | |
'body'=> $r, | |
); | |
/* send mail here */ | |
} | |
function _ajax_call($url, array $posts = array(), $cookie='', $sleep=10) | |
{ | |
$cookie = empty($cookie) ? '' : $cookie; | |
$ch = curl_init(); | |
curl_setopt_array($ch, array( | |
CURLOPT_RETURNTRANSFER => true, | |
CURLOPT_POST => true, | |
CURLINFO_HEADER_OUT => true, | |
CURLOPT_URL => $url, | |
CURLOPT_POSTFIELDS => http_build_query($posts), | |
CURLOPT_USERAGENT => "key='Mojo/IOS'", | |
CURLOPT_COOKIE => $cookie, | |
CURLOPT_HTTPHEADER => array( | |
'X-Requested-With: XMLHttpRequest', | |
'Content-Type: application/x-www-form-urlencoded; charset=UTF-8', | |
), | |
)); | |
if (false === ($json = curl_exec($ch))) { | |
return false; | |
} | |
curl_close($ch); | |
$json = json_decode($json, true); | |
sleep($sleep); | |
return $json; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment