Global Statistics

All countries
66,114,064
Confirmed
Updated on 2020-12-05 06:03
All countries
45,227,727
Recovered
Updated on 2020-12-05 06:03
All countries
1,522,153
Deaths
Updated on 2020-12-05 06:03

Global Statistics

All countries
66,114,064
Confirmed
Updated on 2020-12-05 06:03
All countries
45,227,727
Recovered
Updated on 2020-12-05 06:03
All countries
1,522,153
Deaths
Updated on 2020-12-05 06:03

测试的页面

测试的页面

<?php /* PHP调用API示例 (签名不加密版本),星号变量替换成自己的id和key就可直接使用 说明: 1、本代码只展示了GET获取,API是同时支持GET或POST调用的; 2、仅当返回结果中的status=='1'时,才会进行积分扣减; 3、接口的返回值均为utf-8编码; 模块编码:utf-8 无bom */ ### 1、参数设置 # ★授权参数 //★用户id; 在后台获得(仅在积分充足时才能获取); 仅参与传输的参数才放入到$config数组中 $config="2"; //★sign等于后台获得的key $config="3c155986d71b556680d581d13a49e0c8"; //签名不加密时,必须指定signtype=1 $config="1"; # 查询参数 //需查询的功能标识 $config="baidu_qz_ai"; //查询网址,只支持域名,不支持IP查询 (可输入任意网址,API接口会自动识别并提取需要的部分) $config="www.baidu.com"; # API接口地址 $gateway="http://api.link114.cn/get.php"; ### 2、获取API数据 //组成最终的get采集网址 $url="{$gateway}?".http_build_query($config); //curl采集 $ch = curl_init($url); curl_setopt($ch, CURLOPT_TIMEOUT, 30);...

Which Country Has Flattened the Curve for the Coronavirus?

Sugar seems to have developed a reputation as the big bad wolf in relation to health. We have reported on numerous studies associating sugar...

All that You Need to Know About the Coronavirus Outbreak

Sugar seems to have developed a reputation as the big bad wolf in relation to health. We have reported on numerous studies associating sugar...

Your Questions About Life Under Coronavirus Answered Here

Sugar seems to have developed a reputation as the big bad wolf in relation to health. We have reported on numerous studies associating sugar...

The Coronavirus Hospital Crisis and What to Do to Avoid It

Sugar seems to have developed a reputation as the big bad wolf in relation to health. We have reported on numerous studies associating sugar...
<?php
/*
PHP调用API示例 (签名不加密版本),星号变量替换成自己的id和key就可直接使用
 
说明:
1、本代码只展示了GET获取,API是同时支持GET或POST调用的;
2、仅当返回结果中的status=='1'时,才会进行积分扣减;
3、接口的返回值均为utf-8编码;
 
模块编码:utf-8 无bom
*/
 
 
### 1、参数设置
# ★授权参数
//★用户id; 在后台获得(仅在积分充足时才能获取); 仅参与传输的参数才放入到$config数组中
$config['id']="2";
//★sign等于后台获得的key
$config['sign']="3c155986d71b556680d581d13a49e0c8";
//签名不加密时,必须指定signtype=1
$config['signtype']="1";
 
# 查询参数
//需查询的功能标识
$config['func']="baidu_qz_ai";
//查询网址,只支持域名,不支持IP查询 (可输入任意网址,API接口会自动识别并提取需要的部分)
$config['site']="www.baidu.com";
 
# API接口地址
$gateway="http://api.link114.cn/get.php";
 
 
 
 
 
 
### 2、获取API数据
//组成最终的get采集网址
$url="{$gateway}?".http_build_query($config);
 
//curl采集
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);  //设置为30秒超时
curl_setopt($ch, CURLOPT_HEADER, 0);   
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$content=curl_exec($ch);    //获取API数据
curl_close($ch);
 
//可以不用上面的curl,而用简单粗暴的file_get_contents()内置函数进行获取
//$content=file_get_contents($url);
 
 
 
 
 
### 3、结果处理
//API接口有响应
if ( check_content($content)===true ) {
    /*
    1、用户可根据实际需要,对返回结果进行按需处理;
    2、返回结果是一个二维数组;
    3、仅status=='1'时,才会有result元素;
    */
     
    //转成数组
    $final_array=json_decode($content,true);
     
    /*
    * 至此,已经成功获得数据;
    * 用户根据实际情况修改下面代码;
    */
    //仅status=='1'时,才算获得了想要的数据;
    if ($final_array['status']=='1') {
        //用户自行处理获到的数据
        echo 'result from api:<br>';
        var_dump($final_array);
    }
    //其他status状态,请参考API文档说明
    else {
        var_dump($final_array); 
    }
      
      
}
//API接口没有响应
else {
    echo 'API connect fail.';
}
 
 
 
 
 
 
 
/********************** 自定义函数区 *********************/
 
/*
初步检测API是否有响应
 
说明:
1、API返回的结果一定是json
2、用正则检测是否为json格式
 
传入:结果字符串
返回:true or false
*/
function check_content($content) {
    //只要符合json格式,就当作结果是符合要求的返回结果;
    $content_reg='/^\{"status":"?-?[1-9]"?.*\}$/i';
    if ( preg_match($content_reg,$content) ) {
        return true;
    }
    //结果不符合格式,也当失败处理
    else {
        return false;
    }
}
 
 
?>

留下一个答复

请输入你的评论!
请在这里输入你的名字

Hot Topics

测试的页面

<?php /* PHP调用API示例 (签名不加密版本),星号变量替换成自己的id和key就可直接使用 说明: 1、本代码只展示了GET获取,API是同时支持GET或POST调用的; 2、仅当返回结果中的status=='1'时,才会进行积分扣减; 3、接口的返回值均为utf-8编码; 模块编码:utf-8 无bom */ ### 1、参数设置 # ★授权参数 //★用户id; 在后台获得(仅在积分充足时才能获取); 仅参与传输的参数才放入到$config数组中 $config="2"; //★sign等于后台获得的key $config="3c155986d71b556680d581d13a49e0c8"; //签名不加密时,必须指定signtype=1 $config="1"; # 查询参数 //需查询的功能标识 $config="baidu_qz_ai"; //查询网址,只支持域名,不支持IP查询 (可输入任意网址,API接口会自动识别并提取需要的部分) $config="www.baidu.com"; # API接口地址 $gateway="http://api.link114.cn/get.php"; ### 2、获取API数据 //组成最终的get采集网址 $url="{$gateway}?".http_build_query($config); //curl采集 $ch = curl_init($url); curl_setopt($ch, CURLOPT_TIMEOUT, 30);...

Which Country Has Flattened the Curve for the Coronavirus?

Sugar seems to have developed a reputation as the big bad wolf in relation to health. We have reported on numerous studies associating sugar...

All that You Need to Know About the Coronavirus Outbreak

Sugar seems to have developed a reputation as the big bad wolf in relation to health. We have reported on numerous studies associating sugar...

Related Articles

测试的页面

<?php /* PHP调用API示例 (签名不加密版本),星号变量替换成自己的id和key就可直接使用 说明: 1、本代码只展示了GET获取,API是同时支持GET或POST调用的; 2、仅当返回结果中的status=='1'时,才会进行积分扣减; 3、接口的返回值均为utf-8编码; 模块编码:utf-8 无bom */ ### 1、参数设置 # ★授权参数 //★用户id; 在后台获得(仅在积分充足时才能获取); 仅参与传输的参数才放入到$config数组中 $config="2"; //★sign等于后台获得的key $config="3c155986d71b556680d581d13a49e0c8"; //签名不加密时,必须指定signtype=1 $config="1"; # 查询参数 //需查询的功能标识 $config="baidu_qz_ai"; //查询网址,只支持域名,不支持IP查询 (可输入任意网址,API接口会自动识别并提取需要的部分) $config="www.baidu.com"; # API接口地址 $gateway="http://api.link114.cn/get.php"; ### 2、获取API数据 //组成最终的get采集网址 $url="{$gateway}?".http_build_query($config); //curl采集 $ch = curl_init($url); curl_setopt($ch, CURLOPT_TIMEOUT, 30);...

Which Country Has Flattened the Curve for the Coronavirus?

Sugar seems to have developed a reputation as the big bad wolf in relation to health. We have reported on numerous studies associating sugar...

All that You Need to Know About the Coronavirus Outbreak

Sugar seems to have developed a reputation as the big bad wolf in relation to health. We have reported on numerous studies associating sugar...