HTTP/HTTPS
请求协议
APIUSB / OpenAPI / 行政区划查询接口
行政区划查询接口
接口地址:https://api.apiusb.com/api/app?s=App.Logistics.DistrictQuery
接口描述: 自动提取并填充快递地址所属的省市区行政区划信息,快速提交地址并且提升准确率。
接口参数
参数名字 | 类型 | 是否必须 | 默认值 | 其他 | 说明 |
---|---|---|---|---|---|
access_token | 字符串 | 可选 | 访问令牌,仅当开启签名验证时需要传递,生成令牌可使用App.Auth.ApplyToken接口 | ||
address | 字符串 | 必须 | - | 地址,例如:深圳市南山区金蝶软件园 |
返回字段
返回结果 | 类型 | 说明 |
---|---|---|
ret | 整型 | 状态码,200表示成功,4xx表示客户端非法请求,5xx表示服务器错误 |
data | 对象或混合类型 | 业务数据,由各自接口指定,通常为对象 |
msg | 字符串 | 提示信息,失败时的错误提示 |
在线测试
参数 | 是否必须 | 值 |
---|---|---|
service | 必须 | |
access_token | 可选 | |
address | 必须 |
客户端请求示例
Request:
{Your endpoint domain}/?s=App.Logistics.PackageTrack&address='深圳市南山区金蝶软件园'
Response:
{
"ret": 200,
"data": {
"data": {
"subarea": "金蝶软件园",
"oldFullName": "广东,深圳市,南山区",
"level": 3,
"name": "南山区",
"number": "440305000000",
"pcode": "440300",
"fullName": "广东,深圳市,南山区"
},
"message": "成功",
"result": true,
"returnCode": "200"
},
"msg": "",
}
curl https://api.apiusb.com/api/app?s=App.Logistics.DistrictQuery&address='深圳市南山区金蝶软件园'
{
"ret": 200,
"data": {
"data": {
"subarea": "金蝶软件园",
"oldFullName": "广东,深圳市,南山区",
"level": 3,
"name": "南山区",
"number": "440305000000",
"pcode": "440300",
"fullName": "广东,深圳市,南山区"
},
"message": "成功",
"result": true,
"returnCode": "200"
},
"msg": ""
}
$.ajax({
url: "https://api.apiusb.com/api/app",
data: {s: "App.Logistics.DistrictQuery", address: "深圳市南山区金蝶软件园"},
dataType: 'json',
success: function (response, status, xhr) {
console.log(response);
}
});
<?php
require_once dirname(__FILE__) . '/PhalApiClient.php';
$client = PhalApiClient::create()
->withHost('https://api.apiusb.com/api/app');$rs = $client->reset()
->withService('App.Logistics.DistrictQuery')
->withParams('address', '深圳市南山区金蝶软件园')
->withTimeout(3000)
->request();
// ret状态码,200表示成功
var_dump($rs->getRet());
// 业务数据
var_dump($rs->getData());
// 提示信息
var_dump($rs->getMsg());
#-*- coding:utf-8 -*-
import PhalApiClient
result = PhalApiClient.PhalApiClient('https://api.apiusb.com/api/app', 'App.Logistics.DistrictQueryx', {'address': '深圳市南山区金蝶软件园'}, 3)
//FullscreenActivity.java
import net.phalapi.sdk.*; /**
* 网络操作相关的子线程
*/
Runnable networkTask = new Runnable() {
@Override
public void run() {
// TODO
// 在这里进行 http request.网络请求相关操作
PhalApiClient client = PhalApiClient.create()
.withHost("https://api.apiusb.com/api/app");
PhalApiClientResponse response = client
.withService("App.Logistics.DistrictQuery")
.withParams("address", "深圳市南山区金蝶软件园")
.withTimeout(3000)
.request();
String content = "";
content += "ret=" + response.getRet() + "\n";
if (response.getRet() == 200) {
try {
JSONObject data = new JSONObject(response.getData());
content += "data.title=" + data.getString("title") + "\n";
content += "data.content=" + data.getString("content") + "\n";
content += "data.version=" + data.getString("version") + "\n";
} catch (JSONException ex) {
}
}
content += "msg=" + response.getMsg() + "\n";
Log.v("[PhalApiClientResponse]", content);
Message msg = new Message();
Bundle data = new Bundle();
data.putString("value", content);
msg.setData(data);
handler.sendMessage(msg);
}
};
PhalApiClientResponse response = PhalApiClient.create()
.withHost("https://api.apiusb.com/api/app")
.withService("App.Logistics.DistrictQuery")
.withparamsList("address", "深圳市南山区金蝶软件园")
.withTimeout(3000)
.request();
Log.v("response ret", response.ret + "");
Log.v("response data", response.data);
Log.v("response msg", response.msg);
#import "AFNPhalApiClient.h"// POST
NSDictionary *params = @{@"address": @"深圳市南山区金蝶软件园"};
// Call AFNPhalApiClient
[[[[[AFNPhalApiClient sharedClient] withHost:@"https://api.apiusb.com/api/app"] withService:@"App.Logistics.DistrictQuery"] withParams:params] requestWithFormDataBlock:^(id formData) {
//
[formData appendPartWithFileData:UIImageJPEGRepresentation([UIImage imageNamed:@"head.JPG"], 1) name:@"file" fileName:@"image.jpg" mimeType:@"image/jpeg"];
} completeBlock:^(id resultObject) {
PALog(@"resultObject: %@", resultObject);
} failureBlock:^(NSError *error) {
PALog(@"error: %@", error);
}];
// Print url
PALog(@"total url: %@", [[AFNPhalApiClient sharedClient] printTotalUrlStr]);
错误列表
错误状态码 | 错误描述信息 |
---|---|
400 | 表示客户端参数错误 |
404 | 表示接口服务不存在 |
500 | 表示服务端内部错误 |
本文档生成时间:2024-05-06 09:47:35