PHP站长站备案查询API代码实现
要实现PHP站长站备案查询API代码,首先需要获取站长站的API接口地址和密钥。然后,通过cURL库发送GET请求到API接口,携带必要的参数(如:域名、备案号等)。最后,解析API返回的JSON数据,提取出所需的信息。 以下是一个简单的示例代码: ```php <?php function get_api($url, $key) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $headers = array( 'Authorization: Bear
<?phperror_reporting(0);$u=$_GET['url'];var_dump();if(!isset($u)){echo'?url=qq.com';die;}$a=file_get_contents('http://icp.chinaz.com/info?q='.$u);$p='/<tdalign="left"class="by1"width="30%">(.*?)</td>/';preg_match_all($p,$a,$m);$p1='/<tdalign="left"class="by2"width="30%">(.*?)</td>/';preg_match($p1,$a,$m1);$p2='/<tdwidth="29%"align="left"class="by1">(.*?)</td>/';preg_match($p2,$a,$m2);$p3='/<tdalign="left"class="by2">(.*?)</td>/';preg_match($p3,$a,$m3);$p4='/<tdalign="left"class="by2"width="30%"id="mpage">(.*?)</td>/is';preg_match($p4,$a,$m4);$p5='/<tdalign="left"class="by1">(.*?)</td>/';preg_match_all($p5,$a,$m5);$data['备案号']=$m[1][0];$data['网站名称']=$m[1][1];$data['审核时间']=$m1[1];$data['主办单位']=$m2[1];$data['主办单位性质']=$m3[1];$data['网站首页地址']=$m4[1];$data['网站备案/许可证号']=$m5[1][1];if(strpos($m[0][0],'-')==41){$arr=['code'=>500,'msg'=>'未备案'];print_r(json_encode($arr,JSON_UNESCAPED_UNICODE));}else{print_r(json_encode($data,JSON_UNESCAPED_UNICODE));}