Pois/keyword
Zhangchao2 (讨论 | 贡献) (→JSON示例) |
|||
(未显示2个用户的17个中间版本) | |||
第1行: | 第1行: | ||
− | == ''' | + | == '''pois/keyword''' == |
根据关键字和(或)分类进行搜索,返回相关的poi点信息。 | 根据关键字和(或)分类进行搜索,返回相关的poi点信息。 | ||
== '''URL''' == | == '''URL''' == | ||
− | http://api.t.sina.com.cn/pois/keyword.(json|xml) | + | http://api.t.sina.com.cn/location/pois/keyword.(json|xml) |
== '''支持格式''' == | == '''支持格式''' == | ||
第12行: | 第12行: | ||
== '''是否需要登录''' == | == '''是否需要登录''' == | ||
− | ''' | + | '''true''' |
== '''请求数限制''' == | == '''请求数限制''' == | ||
'''true''' | '''true''' | ||
第28行: | 第28行: | ||
|- | |- | ||
| style="text-align:center;" |q | | style="text-align:center;" |q | ||
− | | style="text-align:center;" | | + | | style="text-align:center;" |false |
| style="text-align:center;" |string | | style="text-align:center;" |string | ||
− | | 查询的关键字 | + | | 查询的关键字,q和category至少填一项 |
|- | |- | ||
| style="text-align:center;" |category | | style="text-align:center;" |category | ||
第36行: | 第36行: | ||
| style="text-align:center;" |string | | style="text-align:center;" |string | ||
| 查询poi分类代码(详见[[location/category|分类代码对应表]]) | | 查询poi分类代码(详见[[location/category|分类代码对应表]]) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
| style="text-align:center;" |city | | style="text-align:center;" |city | ||
第52行: | 第47行: | ||
| 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) |
|} | |} | ||
第65行: | 第60行: | ||
<pre> | <pre> | ||
<?xml version="1.0" encoding="utf-8" ?> | <?xml version="1.0" encoding="utf-8" ?> | ||
− | < | + | <geoResult> |
− | + | ||
<total>695</total> | <total>695</total> | ||
<count>2</count> | <count>2</count> | ||
第72行: | 第66行: | ||
<pois> | <pois> | ||
<poi> | <poi> | ||
− | < | + | <spid>P010A00CHR9</pid> |
<name>123烤鸡翅</name> | <name>123烤鸡翅</name> | ||
<address>石景山区石景山路22号长城大厦附近</address> | <address>石景山区石景山路22号长城大厦附近</address> | ||
第81行: | 第75行: | ||
<longitude>116.22074</longitude> | <longitude>116.22074</longitude> | ||
<latitude>39.90652</latitude> | <latitude>39.90652</latitude> | ||
− | < | + | <city>北京</city> |
+ | <province>北京</city> | ||
</poi> | </poi> | ||
... | ... | ||
</pois> | </pois> | ||
− | </ | + | </geoResult> |
+ | |||
</pre> | </pre> | ||
第91行: | 第87行: | ||
<pre> | <pre> | ||
{ | { | ||
− | + | "total":"695", | |
− | + | ||
"count":"2", | "count":"2", | ||
"page":"1", | "page":"1", | ||
"pois": | "pois": | ||
[{ | [{ | ||
− | " | + | "spid":"P010A00CHR9", |
"name":"123\u70e4\u9e21\u7fc5", | "name":"123\u70e4\u9e21\u7fc5", | ||
− | " | + | "address":"\u77f3\u666f\u5c71\u533a\u77f3\u666f\u5c71\u8def22\u53f7\u957f\u57ce\u5927\u53a6\u9644\u8fd1", |
"category":"50000", | "category":"50000", | ||
"navigator":"\u9910\u996e\u76f8\u5173", | "navigator":"\u9910\u996e\u76f8\u5173", | ||
− | " | + | "telephone":"", |
"pic_url":"", | "pic_url":"", | ||
"longitude":"116.22074", | "longitude":"116.22074", | ||
"latitude":"39.90652", | "latitude":"39.90652", | ||
− | " | + | "city":"北京", |
+ | "province":"北京" | ||
+ | }, | ||
... | ... | ||
− | + | ] | |
} | } | ||
</pre> | </pre> | ||
=== '''字段说明 ''' === | === '''字段说明 ''' === | ||
− | |||
:total:结果总数 | :total:结果总数 | ||
:count:本页返回的结果数 | :count:本页返回的结果数 | ||
:page:返回的首条结果在结果集中的页码 | :page:返回的首条结果在结果集中的页码 | ||
− | : | + | :pois:结果poi集 |
− | :: | + | ::spid:本条poi记录的spid |
− | :: | + | ::name:poi点名称 |
− | + | ::address:poi点的地址 | |
− | + | ::category:poi点的分类(详见分类代码表) | |
− | + | ::navigator:poi点的分类名称 | |
− | + | ::telephone:poi点的电话 | |
− | + | ::pic_url:poi点的图片地址 | |
− | + | ::longitude:poi点的经度 | |
− | + | ::latitude:poi点的纬度 | |
− | ::: | + | ::city:城市 |
+ | ::province:省份 | ||
− | == ''' | + | == '''其它''' == |
+ | |||
+ | === '''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/keyword.xml?source=$appkey&q=$q"; | |
− | http://api.t.sina.com.cn/pois/keyword. | + | |
+ | $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:49的最后版本
目录 |
pois/keyword
根据关键字和(或)分类进行搜索,返回相关的poi点信息。
URL
http://api.t.sina.com.cn/location/pois/keyword.(json%7Cxml)
支持格式
XML/JSON
HTTP请求方式
GET
是否需要登录
true
请求数限制
true
请求参数
参数 | 必选 | 类型及范围 | 说明 |
---|---|---|---|
source | true | string | 申请应用时分配的AppKey,调用接口时候代表应用的唯一身份。 |
q | false | string | 查询的关键字,q和category至少填一项 |
category | false | string | 查询poi分类代码(详见分类代码对应表) |
city | false | string | 城市代码(不填城市代码,默认在全国搜索,详见城市代码对照表) |
注意:一次调用最多只返回50条记录,若有其他需求请及时与我们取得联系 | |||
page | false | int | 返回的首条结果在结果集中的页码(默认为1,最大为40) |
count | false | int | 返回的结果集中每页的结果数(默认为10,最大为50) |
返回结果
XML示例
<?xml version="1.0" encoding="utf-8" ?> <geoResult> <total>695</total> <count>2</count> <page>1</page> <pois> <poi> <spid>P010A00CHR9</pid> <name>123烤鸡翅</name> <address>石景山区石景山路22号长城大厦附近</address> <category>50000</category> <navigator>餐饮相关</navigator> <telephone /> <pic_url /> <longitude>116.22074</longitude> <latitude>39.90652</latitude> <city>北京</city> <province>北京</city> </poi> ... </pois> </geoResult>
JSON示例
{ "total":"695", "count":"2", "page":"1", "pois": [{ "spid":"P010A00CHR9", "name":"123\u70e4\u9e21\u7fc5", "address":"\u77f3\u666f\u5c71\u533a\u77f3\u666f\u5c71\u8def22\u53f7\u957f\u57ce\u5927\u53a6\u9644\u8fd1", "category":"50000", "navigator":"\u9910\u996e\u76f8\u5173", "telephone":"", "pic_url":"", "longitude":"116.22074", "latitude":"39.90652", "city":"北京", "province":"北京" }, ... ] }
字段说明
- total:结果总数
- count:本页返回的结果数
- page:返回的首条结果在结果集中的页码
- pois:结果poi集
- spid:本条poi记录的spid
- name:poi点名称
- address:poi点的地址
- category:poi点的分类(详见分类代码表)
- navigator:poi点的分类名称
- telephone:poi点的电话
- pic_url:poi点的图片地址
- longitude:poi点的经度
- latitude:poi点的纬度
- city:城市
- province:省份
其它
PHP示例
需要开启PHP的cURL扩展
<?php //改为你的微博账号,用户名和密码之间用:隔开 $userPwd = 'user@sina.com:pwd'; //改为你微博应用的appkey $appkey = '0123456789'; //查询关键词 $q = urlencode("123"); $url = "http://api.t.sina.com.cn/location/pois/keyword.xml?source=$appkey&q=$q"; $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