本来是希望给你们自己跟着图抄一遍的 这样才可以记住
不过没关系 需要的话这里补上
<?php
header("Content-type: text/json; charset=utf-8");
error_reporting(0);
$file = "uid";
if(file_exists($file)){
getcomic(file_get_contents($file));
}else{
getcomic(rand_device_id(18));
}
function getcomic($uid){
foreach (getallheaders() as $name => $value) {
if(stristr($name,"uid")){
$header[] = $name.": ".$uid;
}else if(stristr($name,"host")){
}else if(stristr($name,"user-agent")){
$useragent = $value;
}else{
$header[] = $name.": ".$value;
}
}
$requestUrl = 'https://m.samh.xndm.tech/api/v1/comics/getcomicinfo_body?'.'comic_id='.$_GET["comic_id"].'&gender='.$_GET["gender"].'&vip_form='.$_GET["vip_form"].'&client-channel='.$_GET["channel"].'&channel='.$_GET["channel"].'&productname='.$_GET["productname"].'&udid='.$_GET["udid"].'&android_id='.$_GET["android_id"].'&version='.$_GET["version"].'&platform=android&platformname=android&uid='.$uid.'&sessionid='.$_GET["sessionid"];
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt ($ch, CURLOPT_URL, $requestUrl);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_ENCODING, "gzip" );
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
unset($header);
if(strpos($file_contents, '"source_url":""') || empty($file_contents)){
getcomic(rand_device_id(19));
}else{
$fileopen=fopen("uid", "w");
fwrite($fileopen, $uid);
fclose($fileopen);
echo $file_contents;
}
}
function rand_device_id($len)
{
$chars = array('0','1','2','3','4','5','6','7','8','9');
$charsLen = count($chars) - 1;
shuffle($chars);
for ($i=0; $i<$len; $i++)
{
$output .= $chars[mt_rand(0, $charsLen)];
}
return $output;
}
?>
|