Pois/view
Zhangchao2 (讨论 | 贡献) (创建新页面为 '== '''poi/view''' == 根据关键字和(或)分类,在一个矩形里进行搜索,返回相关的poi点信息 == '''URL''' == http://api.t.sina.com.cn/poi/search_view.(…') |
|||
(未显示2个用户的21个中间版本) | |||
第1行: | 第1行: | ||
− | == ''' | + | == '''pois/view''' == |
根据关键字和(或)分类,在一个矩形里进行搜索,返回相关的poi点信息 | 根据关键字和(或)分类,在一个矩形里进行搜索,返回相关的poi点信息 | ||
== '''URL''' == | == '''URL''' == | ||
− | http://api.t.sina.com.cn/ | + | http://api.t.sina.com.cn/location/pois/view.(json|xml) |
== '''支持格式''' == | == '''支持格式''' == | ||
第12行: | 第12行: | ||
== '''是否需要登录''' == | == '''是否需要登录''' == | ||
− | ''' | + | '''true''' |
== '''请求数限制''' == | == '''请求数限制''' == | ||
第19行: | 第19行: | ||
== '''请求参数''' == | == '''请求参数''' == | ||
{| style="width:100%; height:200px;" border="1" cellspacing="0" cellpadding="0" | {| style="width:100%; height:200px;" border="1" cellspacing="0" cellpadding="0" | ||
− | ! style="width:20%;" |参数 | + | ! style="text-align:center;width:20%;" |参数 |
− | ! style="width:10%" |必选 | + | ! style="text-align:center;width:10%" |必选 |
− | ! style="width:20%" |类型及范围 | + | ! style="text-align:center;width:20%" |类型及范围 |
− | ! style="width:50%" |说明 | + | ! style="text-align:center;width:50%" |说明 |
|- style="height:px" | |- style="height:px" | ||
| style="text-align:center;" |source | | style="text-align:center;" |source | ||
第31行: | 第31行: | ||
| style="text-align:center;" |coordinate | | style="text-align:center;" |coordinate | ||
| style="text-align:center;" |true | | style="text-align:center;" |true | ||
− | | style="text-align:center;" | | + | | style="text-align:center;" |string |
| 搜索矩阵(用于视野内搜索)(格式为:x1,y1,x2,y2 其中1代表左下角的点,2代表右上角的点) | | 搜索矩阵(用于视野内搜索)(格式为:x1,y1,x2,y2 其中1代表左下角的点,2代表右上角的点) | ||
|-style="color:red" | |-style="color:red" | ||
− | |colspan=4 | | + | |colspan=4 | 注意:以下两个参数至少选填一个 |
|- | |- | ||
| style="text-align:center;" |q | | style="text-align:center;" |q | ||
第44行: | 第44行: | ||
| style="text-align:center;" |false | | style="text-align:center;" |false | ||
| style="text-align:center;" |string | | style="text-align:center;" |string | ||
− | | 查询poi分类代码(详见[[ | + | | 查询poi分类代码(详见[[Location/category|分类代码对照表]]) |
|- style="color:red" | |- style="color:red" | ||
|colspan=4 | 注意:以下参数选填 | |colspan=4 | 注意:以下参数选填 | ||
第56行: | 第56行: | ||
| style="text-align:center;" |false | | style="text-align:center;" |false | ||
| style="text-align:center;" |string | | style="text-align:center;" |string | ||
− | | 城市代码(不填城市代码,默认在全国搜索,详见[[ | + | | 城市代码(不填城市代码,默认在全国搜索,详见[[Location/citycode|城市代码对照表]]) |
|- | |- | ||
| style="text-align:center;" |page | | style="text-align:center;" |page | ||
| style="text-align:center;" |false | | style="text-align:center;" |false | ||
| style="text-align:center;" |int | | style="text-align:center;" |int | ||
− | | | + | | 返回的首条结果在结果集中的页码(默认为1,最大为40) |
|- | |- | ||
| style="text-align:center;" |count | | style="text-align:center;" |count | ||
| style="text-align:center;" |false | | style="text-align:center;" |false | ||
| style="text-align:center;" |int | | style="text-align:center;" |int | ||
− | | | + | | 返回的结果集中每页的结果数(默认为10,最大为50) |
|} | |} | ||
第74行: | 第74行: | ||
<pre> | <pre> | ||
<?xml version="1.0" encoding="utf-8" ?> | <?xml version="1.0" encoding="utf-8" ?> | ||
− | < | + | <geoSearchResult> |
− | + | ||
<total>1355</total> | <total>1355</total> | ||
<count>2</count> | <count>2</count> | ||
<page>1</page> | <page>1</page> | ||
<coordinates>116.37666,39.93258,116.43943,39.91171</coordinates> | <coordinates>116.37666,39.93258,116.43943,39.91171</coordinates> | ||
− | < | + | <pois> |
− | < | + | <poi> |
− | + | <pid>P010A00183J</pid> | |
− | + | <name>唐益胜饰品店</name> | |
− | + | <address>朝阳门北小街55-1</address> | |
− | + | <category>61209</category> | |
− | + | <navigator>礼品饰品店</navigator> | |
− | + | <telphone /> | |
− | + | <pic_url /> | |
− | + | <longitude>116.42569</longitude> | |
− | + | <latitude>39.93085</latitude> | |
− | + | </poi> | |
− | + | ... | |
− | < | + | </pois> |
− | + | </geoSearchResult> | |
− | + | ||
− | + | ||
− | </ | + | |
− | </ | + | |
</pre> | </pre> | ||
第104行: | 第99行: | ||
<pre> | <pre> | ||
{ | { | ||
− | |||
"total":"1355", | "total":"1355", | ||
"count":"2", | "count":"2", | ||
"page":"1", | "page":"1", | ||
"coordinates":"116.37666,39.93258,116.43943,39.91171", | "coordinates":"116.37666,39.93258,116.43943,39.91171", | ||
− | " | + | "pois": |
[{ | [{ | ||
− | "pid":" | + | "pid":"P010A00183J", |
− | " | + | "name":"\u5510\u76ca\u80dc\u9970\u54c1\u5e97", |
− | "address":"\ | + | "address":"\u671d\u9633\u95e8\u5317\u5c0f\u885755-1", |
− | + | "category":"61209", | |
− | + | "navigator":"\u793c\u54c1\u9970\u54c1\u5e97", | |
− | + | "telephone":"". | |
− | + | "pic_url":"", | |
− | " | + | "longitude":"116.42569", |
− | " | + | "latitude":"39.93085", |
− | " | + | }, |
− | " | + | ... |
− | " | + | ] |
− | " | + | |
− | + | ||
} | } | ||
</pre> | </pre> | ||
− | == ''' | + | === '''字段说明 ''' === |
+ | :total:结果总数 | ||
+ | :count:本页返回的结果数 | ||
+ | :page:返回的首条结果在结果集中的页码 | ||
+ | :coordinates:查询的坐标串 | ||
+ | :pois:结果poi集 | ||
+ | ::pid:本条poi记录的id | ||
+ | ::name:poi点名称 | ||
+ | ::address:poi点的地址 | ||
+ | ::category:poi点的分类(详见分类代码表) | ||
+ | ::navigator:poi点的分类导航名称 | ||
+ | ::telephone:poi点的电话 | ||
+ | ::pic_url:poi点的图片地址 | ||
+ | ::longitude:poi点的经度 | ||
+ | ::latitude:poi点的纬度 | ||
+ | |||
+ | == '''其它''' == | ||
+ | |||
+ | === '''PHP示例''' === | ||
+ | 需要开启PHP的cURL扩展 | ||
<pre> | <pre> | ||
− | + | <?php | |
− | + | //改为你的微博账号,用户名和密码之间用:隔开 | |
+ | $userPwd = 'user@sina.com:pwd'; | ||
+ | //改为你微博应用的appkey | ||
+ | $appkey = '0123456789'; | ||
+ | //查询关键词 | ||
+ | $q = urlencode("123"); | ||
− | + | $url = "http://api.t.sina.com.cn/location/pois/view.xml?q=$q&coordinate=116.37666,39.93258,116.43943,39.91171&source=$appkey"; | |
− | http://api.t.sina.com.cn/pois/view. | + | |
+ | $rst = curlSample($url,$userPwd); | ||
+ | |||
+ | echo $rst; | ||
+ | |||
+ | function curlSample($url,$userPwd,$postFields = '',$header = ''){ | ||
+ | $ch = curl_init() or die (curl_error()) ; | ||
+ | curl_setopt($ch,CURLOPT_URL,$url); | ||
+ | curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); | ||
+ | curl_setopt($ch,CURLOPT_TIMEOUT,30); | ||
+ | if(!empty($userPwd)){ | ||
+ | curl_setopt($ch,CURLOPT_USERPWD,$userPwd); | ||
+ | } | ||
+ | if(!empty($postFields)){ | ||
+ | curl_setopt($ch,CURLOPT_POST,true); | ||
+ | curl_setopt($ch,CURLOPT_POSTFIELDS,$postFields); | ||
+ | } | ||
+ | if(!empty($header)){ | ||
+ | curl_setopt($ch, CURLOPT_HTTPHEADER,$header); | ||
+ | } | ||
+ | $result = curl_exec($ch) or die (curl_error($ch)); | ||
+ | curl_close($ch); | ||
+ | return $result; | ||
+ | } | ||
+ | ?> | ||
</pre> | </pre> |
2012年9月24日 (一) 11:50的最后版本
目录 |
pois/view
根据关键字和(或)分类,在一个矩形里进行搜索,返回相关的poi点信息
URL
http://api.t.sina.com.cn/location/pois/view.(json%7Cxml)
支持格式
XML/JSON
HTTP请求方式
GET
是否需要登录
true
请求数限制
true
请求参数
参数 | 必选 | 类型及范围 | 说明 |
---|---|---|---|
source | true | string | 申请应用时分配的AppKey,调用接口时候代表应用的唯一身份。 |
coordinate | true | string | 搜索矩阵(用于视野内搜索)(格式为:x1,y1,x2,y2 其中1代表左下角的点,2代表右上角的点) |
注意:以下两个参数至少选填一个 | |||
q | false | string | 查询的关键字 |
category | false | string | 查询poi分类代码(详见分类代码对照表) |
注意:以下参数选填 | |||
sign | false | string | 返回值查询关键词标红(y或n,默认为n) |
city | false | string | 城市代码(不填城市代码,默认在全国搜索,详见城市代码对照表) |
page | false | int | 返回的首条结果在结果集中的页码(默认为1,最大为40) |
count | false | int | 返回的结果集中每页的结果数(默认为10,最大为50) |
返回结果
XML示例
<?xml version="1.0" encoding="utf-8" ?> <geoSearchResult> <total>1355</total> <count>2</count> <page>1</page> <coordinates>116.37666,39.93258,116.43943,39.91171</coordinates> <pois> <poi> <pid>P010A00183J</pid> <name>唐益胜饰品店</name> <address>朝阳门北小街55-1</address> <category>61209</category> <navigator>礼品饰品店</navigator> <telphone /> <pic_url /> <longitude>116.42569</longitude> <latitude>39.93085</latitude> </poi> ... </pois> </geoSearchResult>
JSON示例
{ "total":"1355", "count":"2", "page":"1", "coordinates":"116.37666,39.93258,116.43943,39.91171", "pois": [{ "pid":"P010A00183J", "name":"\u5510\u76ca\u80dc\u9970\u54c1\u5e97", "address":"\u671d\u9633\u95e8\u5317\u5c0f\u885755-1", "category":"61209", "navigator":"\u793c\u54c1\u9970\u54c1\u5e97", "telephone":"". "pic_url":"", "longitude":"116.42569", "latitude":"39.93085", }, ... ] }
字段说明
- total:结果总数
- count:本页返回的结果数
- page:返回的首条结果在结果集中的页码
- coordinates:查询的坐标串
- pois:结果poi集
- pid:本条poi记录的id
- name:poi点名称
- address:poi点的地址
- category:poi点的分类(详见分类代码表)
- navigator:poi点的分类导航名称
- telephone:poi点的电话
- pic_url:poi点的图片地址
- longitude:poi点的经度
- latitude:poi点的纬度
其它
PHP示例
需要开启PHP的cURL扩展
<?php //改为你的微博账号,用户名和密码之间用:隔开 $userPwd = 'user@sina.com:pwd'; //改为你微博应用的appkey $appkey = '0123456789'; //查询关键词 $q = urlencode("123"); $url = "http://api.t.sina.com.cn/location/pois/view.xml?q=$q&coordinate=116.37666,39.93258,116.43943,39.91171&source=$appkey"; $rst = curlSample($url,$userPwd); echo $rst; function curlSample($url,$userPwd,$postFields = '',$header = ''){ $ch = curl_init() or die (curl_error()) ; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_TIMEOUT,30); if(!empty($userPwd)){ curl_setopt($ch,CURLOPT_USERPWD,$userPwd); } if(!empty($postFields)){ curl_setopt($ch,CURLOPT_POST,true); curl_setopt($ch,CURLOPT_POSTFIELDS,$postFields); } if(!empty($header)){ curl_setopt($ch, CURLOPT_HTTPHEADER,$header); } $result = curl_exec($ch) or die (curl_error($ch)); curl_close($ch); return $result; } ?>
文档更新时间: 2012-09-24