您现在的位置是:首页> api 个人博客模板
地理位置编码查询
无痕小Q个人博客
2020-03-15 02:36:36【
主页】
1645人已围观
简介本接口可以查询地理位置编码
接口地址https://yzc136.cn/api/open/code
请求方式POST
请求参数 ( 参数名: city , 介绍: 需要查询的地址 , 参数: 北京 。)
返回示例:
{"errors":false,"data":"110000"}
介绍:
地理位置编码查询接口
返回参数
errors:状态
data:城市编码
php代码:
$host = "https://yzc136.cn/api/open/code";
$method = "POST";
$headers = array();
array_push($headers, "Content-Type".":"."application/x-www-form-urlencoded; charset=UTF-8");
$bodys = "city=北京";
$url = $host;
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, true);
if (1 == strpos("$".$host, "https://"))
{
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys);
var_dump(curl_exec($curl));
python代码:
import urllib, urllib2, sys
import ssl
host = 'https://yzc136.cn/class/api/open/code'
path = ''
method = 'POST'
appcode = ''
querys = ''
bodys = {}
url = host + path
bodys['city'] = '北京'
post_data = urllib.urlencode(bodys)
request = urllib2.Request(url, post_data)
request.add_header('Authorization', 'APPCODE ' + appcode)
request.add_header('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8')
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
response = urllib2.urlopen(request, context=ctx)
content = response.read()
if (content):
print(content)
阅读量! (1645)
点击排行
转缺霜输上转迟, 好风偏似送佳期。 帘斜树隔情无限, 烛暗香残坐不辞。 最爱笙调闻北里, 渐看星潆失南箕。 何人为校清凉力, 欲减初圆及午时。
网站公告
- 欢迎来到我的博客
1:欢迎来到我的博客
2:博客免费api接口现已上线
3:博客会定期更新文章
4:欢迎大家来捧场
站点信息
只要点一下就够了蠢 货.没有痛苦我就吸不到能量.
- 建站时间:2019-8-30
- 网站程序:php,laravel-swoole框架
- 今日流量:82(10分钟统计一次)
- 本月流量:31625
- 浏览总量:591936
- 统计方式:中间件,redis消息队列,定时任务
申请链接友情链接
昨夜雨疏风骤,浓睡不消残酒。试问卷帘人,却道海棠依旧。知否,知否,应是绿肥红瘦。