From a5a679b69b732b7bc5095c98e70a56b695685ba1 Mon Sep 17 00:00:00 2001 From: muzihuaner Date: Wed, 18 Mar 2026 13:16:49 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=8F=E6=9C=BA=E8=A7=86=E9=A2=91=EF=BC=8C?= =?UTF-8?q?=E5=A4=A9=E6=B0=94=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/icp/index.php | 110 +++++++++++++++++++++++++++++++++++++++ api/sjsp/index.php | 10 ++++ api/tq/index.php | 126 +++++++++++++++++++++++++++++++++++++++++++++ api_info.json | 52 +++++++++++++++++++ 4 files changed, 298 insertions(+) create mode 100644 api/icp/index.php create mode 100644 api/tq/index.php diff --git a/api/icp/index.php b/api/icp/index.php new file mode 100644 index 0000000..52edf8b --- /dev/null +++ b/api/icp/index.php @@ -0,0 +1,110 @@ + +$url, 'type'=>$type]); + +class icp +{ + private $info = []; + private $array = []; + private $Message; + public function __construct(array $array) + { + /* php构造函数 类初始化时自动运行 */ + foreach($array as $k=>$v) + { + /* for循环获取参数并赋值到类中使用 */ + $this->info[$k] = $v; + } + $this->parameterException(); //调用类中方法 + } + private function parameterException() + { + /* 判断参数是否正常 */ + if(!stristr($this->info['url'], 'http')) + { + $this->info['url'] = 'http://'.$this->info['url']; + } + $host = parse_url($this->info['url'], PHP_URL_HOST); + if(!$host) + { + $this->evaluation(array('code'=>-1, 'text'=>'请输入正确的域名')); + return; + } + $this->run(); //调用方法 + return true; + } + private function Run() + { + $scheme = @parse_url($this->info['url'], PHP_URL_SCHEME); + $host = @parse_url($this->info['url'], PHP_URL_HOST); + $url = $scheme.'://'.$host; + $data = json_decode(trim(preg_replace('/([a-z]+):/i', '"$1":', preg_replace('/jQuery\((.*)\)/', '$1', need::teacher_curl('https://micp.chinaz.com/Handle/AjaxHandler.ashx?action=GetPermit&callback=jQuery&query='.$host.'&type=host&_=1672673081420'))))); + // print_r($data); + if(!isset($data->Typ)) + { + $this->evaluation(array('code'=>-2, 'text'=>'备案数据获取失败')); + return; + } + $String = ''; + $array = array( + 'unit'=>$data->ComName, + 'property'=>$data->Typ, + 'record'=>$data->Permit, + 'hostname'=>$data->WebName, + ); + $String = "主办单位:{$data->ComName}\n单位性质:{$data->Typ}\n网站名字:{$data->WebName}\n网站备案号:{$data->Permit}"; + $String = trim($String, PHP_EOL); + $this->evaluation(array('code'=>1, 'text'=>'获取成功', 'data'=>$array), $String); + return; + } + private function delete() : bool + { + /* 删除已有参数 */ + unset($this->array, $this->Message); + return true; + } + private function evaluation(array $array, $string = false) : bool + { + /* 输出数据 */ + $string = $string ? $string : $array['text']; //判断$string是否存在 + $this->delete(); //调用删除方法 + $this->array = $array; //赋值 + $this->Message = $string; //赋值 + $this->result(); //输出内容 + return true; + } + private function result() + { + $info = $this->info; + $type = isset($info['type']) ? $info['type'] : 'json'; + Switch($type) + { + case 'text': + need::send($this->Message, 'text'); + break; + default: + need::send($this->array, 'json'); + break; + } + return true; + } +} + + + + diff --git a/api/sjsp/index.php b/api/sjsp/index.php index a691b6e..626bb9a 100644 --- a/api/sjsp/index.php +++ b/api/sjsp/index.php @@ -1,3 +1,13 @@ + $msg, 'n'=>$b, 'num'=>$num, 'type'=>$type)); +class 三日天气多选{ + protected $info = []; + protected $Array = []; + protected $Msg; + public function __construct(Array $Array){ + foreach($Array as $k=>$v){ + $this->info[$k] = $v; + } + $this->ParameterException(); + } + protected function ParameterException(){ + $name = $this->info['name']; + if(empty($name)){ + $this->Array = Array('code'=>-1, 'text'=>'请输入地名'); + $this->send(); + return; + } + $n = $this->info['n']; + if($n > 0 && is_numEric($n)){ + $this->info['n'] = $n - 1; + }else{ + $this->info['n'] = false; + } + $num = $this->info['num']; + if($num < 1 && is_numEric($num)){ + $this->info['num'] = 10; + }else{ + $this->info['num'] = 10; + } + $this->Getdata(); + return; + } + protected function Getdata(){ + $name = ($this->info['name']); + $data = need::teacher_curl('http://m.moji.com/api/citysearch/'.$name); + $result = preg_match_all("/{\"cityId\":(.*?),\"city_lable\":(.*?),\"counname\":\"(.*?)\",\"id\":(.*?),\"localCounname\":\"(.*?)\",\"localName\":\"(.*?)\",\"localPname\":\"(.*?)\",\"name\":\"(.*?)\",\"pname\":\"(.*?)\"}/",$data,$nute); + $n = $this->info['n']; + //print_r($nute);exit; + $Array = []; + $num = $this->info['num']; + if($n === false){ + for ($x=0; $x < $result && $x < $num; $x++) { + $jec=$nute[6][$x]; + $je=$nute[7][$x]; + $echo .= ($x+1).":".$je."-".$jec."\n"; + $Array[] = Array('city'=>$je, 'city_t'=>$jec); + } + $this->Msg = trim($echo); + $this->Array = Array('code'=>1, 'text'=>'获取成功', 'data'=>$Array); + $this->send(); + return; + } + $je=$nute[1][$n]; + $jec=$nute[6][$n]; + $data = file_Get_Contents("http://m.moji.com/api/redirect/".$je); + $bb=jiequ($data,"
","
"); + $bb=str_replace(' ', '', $bb); + preg_match_all("//",$bb,$aa); + preg_match_all("/(.*?)<\/em>/",$bb,$qq); + preg_match_all("/
(.*?)<\/strong><\/dd>/",$bb,$cc); + preg_match_all("/(.*?)<\/p>/",$bb,$dd); + preg_match_all("/
(.*?)<\/dd>/",$bb,$ee); + preg_match_all("/
(.*?)<\/dd>/",$bb,$ff); + if(empty($aa[2][0])){ + $this->Msg = '不支持'; + $this->Array = Array('code'=>-2, 'text'=>'不支持'); + $this->send(); + return; + } + $this->Msg = "☁.查询:".$jec."\n☁.日期:".$qq[1][0]."\n☁.温度:".$aa[2][0]."~".$aa[1][0]."℃\n☁.天气:".$cc[1][0]."\n☁.风度:".$ee[1][2]."-".$ff[1][3]."\n☁.空气质量:".$dd[2][0]."\n\n☁.日期:".$qq[1][1]."\n☁.温度:".$aa[2][1]."~".$aa[1][1]."℃\n☁.天气:".$cc[1][1]."\n☁.风度:".$ee[1][6]."-".$ff[1][7]."\n☁.空气质量:".$dd[2][1]."\n\n☁.日期:".$qq[1][2]."\n☁.温度:".$aa[2][2]."~".$aa[1][2]."℃\n☁.天气:".$cc[1][2]."\n☁.风度:".$ee[1][10]."-".$ff[1][11]."\n☁.空气质量:".$dd[2][2].""; + + $this->Array = Array('code'=>1, 'text'=>'获取成功', 'data'=>Array('city'=>$jec, 'data'=>Array(Array('Time'=>$qq[1][0], 'temperature'=>$aa[2][0]."~".$aa[1][0]."℃", 'weather'=>$cc[1][0], 'bearing'=>$ee[1][2]."-".$ff[1][3], 'air_quality'=>$dd[2][0]), Array('Time'=>$qq[1][1], 'temperature'=>$aa[2][1]."~".$aa[1][1]."℃", 'weather'=>$cc[1][1], 'bearing'=>$ee[1][6]."-".$ff[1][7], 'air_quality'=>$dd[2][1]), Array('Time'=>$qq[1][2], 'temperature'=>$aa[2][2]."~".$aa[1][2]."℃", 'weather'=>$cc[1][2], 'bearing'=>$ee[1][10]."-".$ff[1][11], 'air_quality'=>$dd[2][2])))); + $this->send(); + return; + } + public function send(){ + $type = $this->info['type']; + $data = $this->Array; + if($data['data']['city']){ + Switch($type){ + case 'text': + need::send($this->Msg, 'text'); + break; + default: + need::send($data); + break; + } + }else{ + Switch($type){ + case 'text': + need::send($this->Msg, 'text'); + break; + default: + need::send($data); + break; + } + } + } +} diff --git a/api_info.json b/api_info.json index d95cbc9..2bc5122 100644 --- a/api_info.json +++ b/api_info.json @@ -297,6 +297,58 @@ "description": "返回格式[json|text],默认为json。json返回视频信息,text返回格式化文本" } ] + }, + { + "name": "ICP备案查询", + "description": "查询网站的ICP备案信息,返回主办单位、网站名称、备案号等信息", + "path": "/api/icp/index.php", + "method": "GET", + "params": [ + { + "name": "url", + "type": "string", + "required": true, + "description": "要查询的网站URL或域名" + }, + { + "name": "type", + "type": "string", + "required": false, + "description": "返回格式[json|text],默认为json。json返回完整备案数据,text返回格式化文本" + } + ] + }, + { + "name": "天气查询", + "description": "查询指定城市的天气信息,支持返回3天天气预报,包含温度、天气状况、风力等信息", + "path": "/api/tq/index.php", + "method": "GET", + "params": [ + { + "name": "msg", + "type": "string", + "required": true, + "description": "城市名称或地名" + }, + { + "name": "b", + "type": "integer", + "required": false, + "description": "选择第几个城市结果(当搜索结果多于1个时),不提供则返回所有搜索结果列表" + }, + { + "name": "num", + "type": "integer", + "required": false, + "description": "返回结果数量,默认为10" + }, + { + "name": "type", + "type": "string", + "required": false, + "description": "返回格式[json|text],默认为json" + } + ] } ] }