接口地址:http://realip.cc |
---|
返回格式:json |
请求方式:get/post |
请求示例:http://realip.cc/?ip=1.1.1.1 |
名称 | 类型 | 必填 | 说明 |
---|---|---|---|
ip | string | 选填 | ip地址,不填则为访问ip |
名称 | 类型 | 说明 |
---|---|---|
ip | string | ip地址 |
city | string | 城市拼音 |
province | string | 省份 |
country | string | 国家英文 |
continent | string | 洲 |
time_zone | string | 时区 |
latitude | string | 经度 |
longitude | string | 纬度 |
{
"ip": "157.0.138.246",
"city": "Kunshan",
"province": "Jiangsu",
"country": "China",
"continent": "Asia",
"isp": "CHINA UNICOM China169 Backbone",
"time_zone": "Asia/Shanghai",
"latitude": 31.3862,
"longitude": 120.9496,
"postal_code": null,
"iso_code": "CN",
"network": "157.0.136.0/21",
"notice": "希望疫情早日过去",
"provider": "Powered by Bboysoul",
"blog": "https://www.bboy.app",
"data_updatetime": "20220503",
"count": 123561
}
错误码 | 说明 |
---|---|
- | - |
<?php
/**
* Created by PhpStorm.
* User: FZS
* Time: 2022/05/01 11:38
*/
class freeApi
{
private $apiUrl;
public function __construct()
{
$this->apiUrl = 'http://realip.cc/?ip=1.1.1.1';
}
/**
* 获取结果
* @return array
*/
public function getResult()
{
return file_get_contents($this->apiUrl);
}
}
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
const (
APIURL = "http://realip.cc/?ip=1.1.1.1"
)
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))
}