Pois/view

跳转到: 导航, 搜索
(XML示例)
 
(未显示2个用户的18个中间版本)
第1行: 第1行:
== '''poi/view''' ==
+
== '''pois/view''' ==
 
根据关键字和(或)分类,在一个矩形里进行搜索,返回相关的poi点信息
 
根据关键字和(或)分类,在一个矩形里进行搜索,返回相关的poi点信息
  
 
== '''URL''' ==
 
== '''URL''' ==
http://api.t.sina.com.cn/poi/search_view.(json|xml)
+
http://api.t.sina.com.cn/location/pois/view.(json|xml)
  
 
== '''支持格式''' ==
 
== '''支持格式''' ==
第12行: 第12行:
  
 
== '''是否需要登录''' ==
 
== '''是否需要登录''' ==
'''false'''
+
'''true'''
  
 
== '''请求数限制''' ==
 
== '''请求数限制''' ==
第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;" |float
+
| 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
第61行: 第61行:
 
| 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,最大为50)
+
| 返回的结果集中每页的结果数(默认为10,最大为50)
 
|}
 
|}
  
第75行: 第75行:
 
<?xml version="1.0" encoding="utf-8" ?>  
 
<?xml version="1.0" encoding="utf-8" ?>  
 
<geoSearchResult>
 
<geoSearchResult>
  <result>1</result>
 
 
   <total>1355</total>  
 
   <total>1355</total>  
 
   <count>2</count>  
 
   <count>2</count>  
第82行: 第81行:
 
   <pois>
 
   <pois>
 
   <poi>
 
   <poi>
  <pid>0010_70585</pid>  
+
    <pid>P010A00183J</pid>  
  <name>中共东城区纪委信访接待室(...</name>  
+
    <name>唐益胜饰品店</name>  
  <address>育群胡同1号</address>  
+
    <address>朝阳门北小街55-1</address>
  <pic_urlS />  
+
    <category>61209</category>  
  <gc>116.41603 39.92913</gc>  
+
    <navigator>礼品饰品店</navigator>
  <bus>1</bus>  
+
    <telphone />
 +
    <pic_url />
 +
    <longitude>116.42569</longitude>  
 +
    <latitude>39.93085</latitude>  
 
   </poi>
 
   </poi>
 
   ...
 
   ...
第97行: 第99行:
 
<pre>
 
<pre>
 
{
 
{
  "result":"1",
 
 
   "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",
   "list":
+
   "pois":
 
   [{
 
   [{
     "pid":"0010_70585",
+
     "pid":"P010A00183J",
     "title":"\u4e2d\u5171\u4e1c\u57ce\u533a\u7eaa\u59d4\u4fe1\u8bbf\u63a5\u5f85\u5ba4(...",
+
     "name":"\u5510\u76ca\u80dc\u9970\u54c1\u5e97",
     "address":"\u80b2\u7fa4\u80e1\u540c1\u53f7",
+
     "address":"\u671d\u9633\u95e8\u5317\u5c0f\u885755-1",
    "pic_urlS":"",
+
     "category":"61209",
    "gc":"116.41603 39.92913",
+
     "navigator":"\u793c\u54c1\u9970\u54c1\u5e97",
    "bus":"1"},
+
     "telephone":"".
  {
+
     "pic_url":"",
     "pid":"0010_669424",
+
     "longitude":"116.42569",
     "title":"\u7687\u671d\u5a31\u4e50",
+
     "latitude":"39.93085",
     "address":"\u534e\u4fa8\u5927\u53a6B1",
+
  },
     "pic_urlS":"",
+
  ...
     "gc":"116.41146 39.92348",
+
  ]
     "bus":"1"
+
    }]
+
 
}
 
}
  
 
</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>
xml:
+
<?php
http://api.t.sina.com.cn/pois/view.xml?q=1&coordinate=116.37666,39.93258,116.43943,39.91171&source=appkey
+
//改为你的微博账号,用户名和密码之间用:隔开
 +
$userPwd = 'user@sina.com:pwd';
 +
//改为你微博应用的appkey
 +
$appkey = '0123456789';
 +
//查询关键词
 +
$q = urlencode("123");
  
json:
+
$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.json?q=1&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;
 +
}
 +
?>
 
</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