接口地址:https://v2.alapi.cn/api/ip |
---|
返回格式:json/text |
请求方式:get/post |
请求示例:https://v2.alapi.cn/api/ip?ip=114.114.114.114&token=token |
名称 | 类型 | 必填 | 说明 |
---|---|---|---|
token | string | 必填 | 请求token 扫码关注公众号 |
ip | string | 必填 | 要查询的 ip |
format | string | 选填 | 默认返回 json 格式,返回文本参数为 text |
名称 | 类型 | 说明 |
---|---|---|
- | - | - |
{
"code": 200,
"msg": "success",
"data": {
"beginip": "101.229.176.0",
"endip": "101.231.74.127",
"pos": "中国上海市上海市宝山区",
"isp": "电信",
"location": {
"lat": 31.40527,
"lng": 121.48941
},
"rectangle": "120.8397067,30.77980118;122.1137989,31.66889673",
"ad_info": {
"nation": "中国",
"province": "上海市",
"city": "上海市",
"district": "宝山区",
"adcode": 310113
},
"ip": "101.229.241.224"
},
"Author": {
"name": "Alone88",
"desc": "由Alone88提供的免费API 服务,官方文档:www.alapi.cn"
}
}
错误码 | 说明 |
---|---|
404 | api 地址错误 |
422 | 请输入正确的 IP |
<?php
/**
* Created by PhpStorm.
* User: FZS
* Time: 2020/02/01 00:16
*/
class freeApi
{
private $apiUrl;
public function __construct()
{
$this->apiUrl = 'https://v1.alapi.cn/api/ip';
}
/**
* 获取结果
* @return array
*/
public function getResult()
{
return file_get_contents($this->apiUrl);
}
}
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
const (
APIURL = "https://v1.alapi.cn/api/ip"
)
func main() {
queryUrl := fmt.Sprintf("%s",APIURL)
resp, err := http.Get(queryUrl)
if err != nil {
log.Println(err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}