接口地址:https://www.mxnzp.com/api/ip/self |
---|
返回格式:json |
请求方式:get |
请求示例:https://www.mxnzp.com/api/ip/self?app_id=your&app_secret=your |
名称 | 类型 | 必填 | 说明 |
---|---|---|---|
app_id | string | 必填 | app_id 扫码关注公众号 |
app_secret | string | 必填 | app_secret 扫码关注公众号 |
名称 | 类型 | 说明 |
---|---|---|
ip | string | 访问者的ip地址 |
province | string | 省份 |
code | string | 省份id |
city | string | 城市 |
cityId | string | 城市id |
isp | string | 网络服务商名称 例如 电信 |
desc | string | 拼接好的描述信息 |
{
"code": 1,
"msg": "数据返回成功!",
"data": {
"ip": "124.77.84.179",
"province": "上海市",
"provinceId": 310000,
"city": "上海市",
"cityId": 310000,
"isp": "/闸北区电信",
"desc": "上海市上海市 /闸北区电信"
}
}
错误码 | 说明 |
---|---|
0 | app_id或者app_secret不合法 |
<?php
/**
* Created by PhpStorm.
* User: FZS
* Time: 2022/06/01 11:38
*/
class freeApi
{
private $apiUrl;
public function __construct()
{
$this->apiUrl = 'https://www.mxnzp.com/api/ip/self?app_id=your&app_secret=your';
}
/**
* 获取结果
* @return array
*/
public function getResult()
{
return file_get_contents($this->apiUrl);
}
}
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
const (
APIURL = "https://www.mxnzp.com/api/ip/self?app_id=your&app_secret=your"
)
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))
}