type
Post
status
Published
date
Mar 31, 2023
slug
3
summary
tags
category
技术分享
icon
password

pingAPI请求方式

Method: GET

请求地址

参数

url=要ping的域名

调用示例

源码

<?php $url = $_GET['url']; $port = '80'; $num = 1; //Ping次数 function mt_f (){ list($usec,$sec) = explode(" ",microtime()); return ((float)$usec + (float)$sec); } function ping_f($url,$port){ $time_s = mt_f(); $ip = gethostbyname($url); $fp = @fsockopen($url,$port); if(!$fp) return '回复超时!'; $get = "GET / HTTP/1.1||Host:".$url."||Connect:".$port."Close||"; fputs($fp,$get); fclose($fp); $time_e = mt_f(); $time = $time_e - $time_s; $time = ceil($time * 1000); return '时间 = '.$time.'ms'; } for($i = 0;$i < $num;$i++){ echo '正在PING: '.$url.' 来自 '.gethostbyname($url).' 的回复 '.ping_f($url,$port).'</br>'; sleep(0.1);//每次运行中间间隔0.1s ob_flush(); flush(); } ?>
 
每天 60 秒读懂世界 API新闻早报

ingm23
ingm23
一个普通的干饭人🍚
公告
type
Notice
status
Published
date
Jul 2, 2021
slug
#
summary
tags
category
icon
password