微信域名拦截检测php源码

 1 <?php
 2   
 3 /**
 4 * 微信域名拦截检测
 5 */
 6   
 7 // 页面编码
 8 header("Content-type:application/json");
 9   
10 // 隐藏WARNING
11 error_reporting(E_ALL ^ E_WARNING);
12   
13 // 获取headers
14 $checkUrl = get_headers('http://mp.weixinbridge.com/mp/wapredirect?url='.$_REQUEST['url']);
15 $headerStr = json_encode($checkUrl);
16   
17 // 提取Location后面的
18 $Location_behind = substr($headerStr, strripos($headerStr, "Location"));
19   
20 // 判断域名状态
21 if($Location_behind == 'false'){
22       
23     // 该域名无法正常访问
24     $result = array(
25         'code' => 201,
26         'msg' => '该域名无法正常访问,暂时无法查询访问状态'
27     );
28 }else if(strpos($Location_behind,'weixin110') !== false){
29       
30     // Location后面包含weixin110就是被封了
31     // 域名被封
32     $result = array(
33         'code' => 202,
34         'msg' => '域名被封'
35     );
36 }else{
37       
38     // 域名被封
39     $result = array(
40         'code' => 200,
41         'msg' => '域名正常'
42     );
43 }
44   
45 // 输出JSON
46 echo json_encode($result,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
47   
48 ?>

 

posted @ 2023-05-16 10:49  安语未  阅读(95)  评论(0编辑  收藏  举报