MIP最简单的推送方式:
宝塔→计划任务→访问URL
新建一个TXT文本把代码复制进去→内容修改后【后缀改为PHP】→上传宝塔根目录→访问地址(网站+文本名字)
以下代码自己填写的地方,我都飘红了
<?php $server_name = @$_GET['dm']; $token = @$_GET['token']; $time = @date('Ymd'); function rand_str($length = 5) { $str = ''; $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"; $max = strlen($strPol)-1; for($i = 0; $i < $length; $i++) { $str .=$strPol[rand(0,$max)]; } return $str; } $count = 50; //填写推送条数 $urls = array(); for ($i = 0; $i < $count; $i++) { $urls[] = "XXXXX(填写域名){$server_name}/{$time}/".rand_str().rand_str().'.html'; }
$api = "http://data.zz.baidu.com/urls?site=www.xxxx.com&token=XXXXXX&type=mip";
$ch = curl_init(); $options = array( CURLOPT_URL => $api, CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => implode("\n", $urls), CURLOPT_HTTPHEADER => array('Content-Type: text/plain'), ); curl_setopt_array($ch, $options); $result = curl_exec($ch); echo "mip推送",$result; ?>
|