PHP 通过curl POST传递 伪造cookie 传递信息
一些论坛网站需要每日签到太麻烦,于是写了一个Win 的定时任务,通过curl 去处理传递的伪造Cookie 和 header;
有不妥的地方,希望各位大佬们多多指正,谢谢各位大佬:
$fp = @fopen("test.txt", "a+");
$error = @fopen("error.txt", "a+");
date_default_timezone_set("PRC");
$data = date("Y-m-d H:i:s",time());
$result = data();
if ($result['info'] == '操作成功') {
fwrite($fp , $data. " ping成功!\r\n");fclose($fp);
}else{
fwrite($error , $data. " ping失败!\r\n");fclose($error);
}
function data($url){
header("Content-type:text/html;Charset=utf8");
$ch =curl_init();
curl_setopt($ch,CURLOPT_URL,'https://www.proginn.com/api/remote/ping');
$header = array();
curl_setopt($ch,CURLOPT_HEADER,true);
// 将Transfer作为字符串返回
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// 关闭SSL验证
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
curl_setopt($ch,CURLOPT_COOKIE,' ######通过浏览器去看传递过去的信息#####');
$content = curl_exec($ch);
curl_close($ch);
//处理返回的数据,通过正则处理json数据后,返回
preg_match("/{.+}/", $content,$result);
return json_decode($result[0],1);
}