域名备案
其他 官方文档
根据域名查询域名备案状态
基本说明:
接口地址:http://icp.fleacloud.com/api/v1/icp
返回格式:json
请求方式:get
请求示例:http://icp.fleacloud.com/api/v1/icp?domain=baidu.com
请求参数说明:
名称 类型 必填 说明
domain string 必填 要查询的域名
返回参数说明:
名称 类型 说明
status int 备案状态
icp string 如果备案状态正常,为备案号,否则为空
JSON返回示例:
{
	"status": 3,
	"icp": "京ICP证030173号-1"
}
服务级错误码参照
错误码 说明
0 未知
1 查询失败
2 未备案或备案过期
3 备案状态正常
完整教学代码示例
<?php
/**
 * Created by PhpStorm.
 * User: FZS
 * Time: 2019/9/3 23:10
 */
//----------------------------------
// 域名备案 调用类
//----------------------------------
class freeApi{
    private $apiUrl;

    public function __construct(){
        $this->apiUrl = 'http://icp.fleacloud.com/api/v1/icp?domain=baidu.com';
    }
    /**
     * 获取结果
     * @return array
     */
    public function getResult(){
        return $this->freeApiCurl($this->apiUrl);
    }
    /**
     * 请求接口返回内容
     * @param  string $url [请求的URL地址]
     * @param  string $params [请求的参数]
     * @param  int $ipost [是否采用POST形式]
     * @return  string
     */
    public function freeApiCurl($url,$params=false,$ispost=0){
        $ch = curl_init();
        curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );
        curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );
        curl_setopt( $ch, CURLOPT_USERAGENT , 'free-api' );
        curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 );
        curl_setopt( $ch, CURLOPT_TIMEOUT , 60);
        curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true );
        if( $ispost )
        {
            curl_setopt( $ch , CURLOPT_POST , true );
            curl_setopt( $ch , CURLOPT_POSTFIELDS , $params );
            curl_setopt( $ch , CURLOPT_URL , $url );
        }
        else
        {
            if($params){
                curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params );
            }else{
                curl_setopt( $ch , CURLOPT_URL , $url);
            }
        }
        $response = curl_exec( $ch );
        if ($response === FALSE) {
            return false;
        }
        curl_close( $ch );
        return $response;
    }
}