# 屏蔽云端爬虫检测

本功能对应的PHP SDK:<https://github.com/wechaturl/wechat_url_api/blob/master/CheckIp_example.php>

> 经过大数据分析发现，大部分云厂商会非法劫持http流量，或许比我们想象的严重，有部分大厂对劫持的内容做隐私大数据分析。

**请求URL：**

* `https://wechaturl.us/api/CheckIp.json`

**请求方式：**

* POST 或者GET(如果用GET,特殊字符串需要url编码)

**参数：**

| 参数名    | 必选 | 类型     | 说明                                                    |
| ------ | -- | ------ | ----------------------------------------------------- |
| appid  | 是  | int    | <http://www.wechaturl.us/user/index.html> 去免费获取appid  |
| appkey | 是  | string | <http://www.wechaturl.us/user/index.html> 去免费获取appkey |
| ip     | 是  | string | ip地址，目前只支持ipV4                                        |

**返回示例，**

* `https://wechaturl.us/api/CheckIp.json?appid=37****15&appkey=a50d38748960******80ae1a725b7c95&ip=124.225.192.171`

```
{
  "code": 1,
  "msg": "blocked",
  "ip": "124.225.192.171",
  "message": "this ip is in blacklist.search_range 是本次检索范围。详细请咨询客服",
  "search_range": [
    "line",
    "tencent",
    "telegram",
    "360",
    "whatsapp",
    "alibaba",
    "facebook",
    "bytedance",
    "skype"
  ],
  "show_error_url": "https://www.google.com/error"
}
#请将上面的信息保存到session
```

#### &#x20;返回结果怎么用

1. 如果code=1,被拦截,直接给浏览器返回错误页面，如下面的例子;

&#x20;      code=0,不被拦截;

&#x20;      code>1,存在其他错误([详细查看](https://wechaturl.gitbook.io/wechaturl/code_summary#code-zhuang-tai-ma))

&#x20;  2\. search\_range 是本次检索范围,目前已经支持主流厂商和浏览器.但是有些检索范围必须是“至尊会员+“，才能使用”。其中bytedance是今日头条和抖音+tiktok.详细请咨询客服

```
php:
new:: https://github.com/wechaturl/wechat_url_api/blob/master/CheckIp_example.php
<?php
if(is_numeric($CheckIpResult['code']) and $CheckIpResult['code']>1){
    exit($CheckIpResult['message']);
}else if($CheckIpResult['code']==1){
    //here,show  error page
    //http_response_code(404);
    //exit('page no found!');
    if(isset($CheckIpResult['show_error_url'])){
        exit(file_get_contents($CheckIpResult['show_error_url']));//当然,你可以自己写个网址
    }else{
        exit('page no found!');
    }
}
//下面就是你的代码
//echo '这里写你的代码吧';
?>
<?php 
//如果你的是静态单页面网站或者vue单页面,如./default.html,那使用下面方法
//echo file_get_contents('./default.html')
?>
```

[**查看所有CODE、STATUS值含义**](https://github.com/wanjunlengfeng/WechatUrlCheckPreventingBlockedApi/blob/master/%E5%BE%AE%E4%BF%A1%E9%98%B2%E5%B0%81%E6%9D%80%E7%B3%BB%E7%BB%9Fapi%E6%8E%A5%E5%8F%A3%E8%AF%A6%E7%BB%86%E8%AF%B4%E6%98%8E/CODE%E4%BB%A3%E7%A0%81%E6%B1%87%E6%80%BB.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wechaturl.gitbook.io/wechaturl/check_ip.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
