继上篇文章利用钉钉机器人推送消息

<?php
/**
 * php 监控网站状态
 * User: 神奇的七云
 * Date: 2020/4/15
 * Time: 16:23
 */
set_time_limit(0);
$urls=array(
    'https://blog.qqiyu.cn/',
    'https://v1.qqiyu.cn/',
  'https://story.qqiyu.cn/',
  'http://love.qqiyu.cn/',
  'http://music.qqiyu.cn/',
  'https://onecdn.qqiyu.cn/'
);
 
foreach ($urls as $url) {
    $resCode=getCode($url);
    if (strpos($resCode,'200')===false) {
        $pass = md5(md5(date("Ymdhis", time())-66547997));
          $time= date("Y-m-d h:i:s",time());
       $debug= getCode('http://上篇文章那个api/ding.php?type=text&content='.$url."   不能正常访问 错误码:".$resCode."  ".$time.'&key='.$pass);
        $arr=json_decode($debug,true);
        echo "$url.不能正常访问";
        echo "错误码".$resCode."</br>";
    }else
    {
        echo $url." 正常访问!<br/>";

    }
}

function getCode($url)
{
    $ch = curl_init ();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_TIMEOUT, 200);
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
    curl_setopt($ch, CURLOPT_NOBODY, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
    curl_exec($ch);
    $httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
    curl_close($ch);
    return $httpCode;
}
最后修改:2020 年 04 月 15 日 06 : 47 PM
如果觉得我的文章对你有用,请随意赞赏