Pois/keyword

跳转到: 导航, 搜索
(JSON示例)
 
(未显示2个用户的7个中间版本)
第1行: 第1行:
== '''关键字搜索''' ==
+
== '''pois/keyword''' ==
 
根据关键字和(或)分类进行搜索,返回相关的poi点信息。
 
根据关键字和(或)分类进行搜索,返回相关的poi点信息。
  
 
== '''URL''' ==
 
== '''URL''' ==
http://api.map.sina.com.cn/pois/keyword.(json|xml)
+
http://api.t.sina.com.cn/location/pois/keyword.(json|xml)
  
 
== '''支持格式''' ==
 
== '''支持格式''' ==
第12行: 第12行:
  
 
== '''是否需要登录''' ==
 
== '''是否需要登录''' ==
'''false'''  
+
'''true'''  
 
== '''请求数限制''' ==
 
== '''请求数限制''' ==
 
'''true'''  
 
'''true'''  
第28行: 第28行:
 
|-
 
|-
 
| style="text-align:center;" |q
 
| style="text-align:center;" |q
| style="text-align:center;" |true
+
| 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;" |sign
 
| style="text-align:center;" |false
 
| style="text-align:center;" |string
 
| 返回值查询关键词标红(y或n,默认为n)
 
 
|-
 
|-
 
| style="text-align:center;" |city
 
| style="text-align:center;" |city
第47行: 第42行:
 
| 城市代码(不填城市代码,默认在全国搜索,详见[[location/citycode|城市代码对照表]])
 
| 城市代码(不填城市代码,默认在全国搜索,详见[[location/citycode|城市代码对照表]])
 
|- style="color:red"  
 
|- style="color:red"  
|colspan=4 | 注意:一次调用最多只返回40条记录,若有其他需求请及时与我们取得联系
+
|colspan=4 | 注意:一次调用最多只返回50条记录,若有其他需求请及时与我们取得联系
 
|-
 
|-
 
| 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,最大为10)
+
| 返回的首条结果在结果集中的页码(默认为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
| 返回的结果集中每页的结果数(默认为20,最大为40)
+
| 返回的结果集中每页的结果数(默认为10,最大为50)
 
|}
 
|}
  
第65行: 第60行:
 
<pre>
 
<pre>
 
<?xml version="1.0" encoding="utf-8" ?>  
 
<?xml version="1.0" encoding="utf-8" ?>  
<geoSearchResult>
+
<geoResult>
  <result>1</result>  
+
 
   <total>695</total>  
 
   <total>695</total>  
 
   <count>2</count>  
 
   <count>2</count>  
第72行: 第66行:
 
   <pois>
 
   <pois>
 
   <poi>
 
   <poi>
     <pid>P010A00CHR9</pid>  
+
     <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>
</geoSearchResult>
+
</geoResult>
 +
 
 
</pre>
 
</pre>
  
第90行: 第87行:
 
<pre>
 
<pre>
 
{
 
{
"result":"1",
+
"total":"695",
"total":"695",
+
 
  "count":"2",
 
  "count":"2",
 
  "page":"1",
 
  "page":"1",
 
  "pois":
 
  "pois":
 
   [{
 
   [{
     "pid":"P010A00CHR9",
+
     "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",
 
     "address":"\u77f3\u666f\u5c71\u533a\u77f3\u666f\u5c71\u8def22\u53f7\u957f\u57ce\u5927\u53a6\u9644\u8fd1",
第104行: 第100行:
 
     "pic_url":"",
 
     "pic_url":"",
 
     "longitude":"116.22074",
 
     "longitude":"116.22074",
     "latitude":"39.90652"
+
     "latitude":"39.90652",
 +
    "city":"北京",
 +
"province":"北京"
 
     },
 
     },
 
     ...
 
     ...
第112行: 第110行:
  
 
=== '''字段说明 ''' ===
 
=== '''字段说明 ''' ===
:result:是否有结果(0为没有搜索到结果,1为有搜索结果)
 
 
:total:结果总数
 
:total:结果总数
 
:count:本页返回的结果数
 
:count:本页返回的结果数
 
:page:返回的首条结果在结果集中的页码
 
:page:返回的首条结果在结果集中的页码
 
:pois:结果poi集
 
:pois:结果poi集
:::pid:本条poi记录的id
+
::spid:本条poi记录的spid
:::name:poi点名称
+
::name:poi点名称
:::address:poi点的地址
+
::address:poi点的地址
:::category:poi点的分类(详见分类代码表)
+
::category:poi点的分类(详见分类代码表)
:::navigator:poi点的分类名称
+
::navigator:poi点的分类名称
:::telephone:poi点的电话
+
::telephone:poi点的电话
:::pic_url:poi点的图片地址
+
::pic_url:poi点的图片地址
:::longitude:poi点的经度
+
::longitude:poi点的经度
:::latitude:poi点的纬度
+
::latitude:poi点的纬度
 +
::city:城市
 +
::province:省份
  
== '''使用示例''' ==
+
== '''其它''' ==
 +
 
 +
===  '''PHP示例''' ===
 +
需要开启PHP的cURL扩展
 
<pre>
 
<pre>
xml:
+
<?php
http://api.map.sina.com.cn/pois/keyword.xml?q=123&city=0010&source=appkey
+
//改为你的微博账号,用户名和密码之间用:隔开
 +
$userPwd = 'user@sina.com:pwd';
 +
//改为你微博应用的appkey
 +
$appkey = '0123456789';
 +
//查询关键词
 +
$q = urlencode("123");
  
json:
+
$url = "http://api.t.sina.com.cn/location/pois/keyword.xml?source=$appkey&q=$q";
http://api.map.sina.com.cn/pois/keyword.json?q=123&city=0010&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;
 +
}
 +
?>
 
</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