Pois/get poi

跳转到: 导航, 搜索
 
(未显示1个用户的3个中间版本)
第16行: 第16行:
 
== '''请求参数''' ==
 
== '''请求参数''' ==
 
{| style="width:100%; height:100px;" border="1" cellspacing="0" cellpadding="0"
 
{| style="width:100%; height:100px;" 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  
第112行: 第112行:
 
::spid:POI点的SPID
 
::spid:POI点的SPID
  
== '''使用示例''' ==
+
== '''其它''' ==
  
 +
===  '''PHP示例''' ===
 +
需要开启PHP的cURL扩展
 
<pre>
 
<pre>
json:
+
<?php
curl -u "username:password" "http://api.t.sina.com.cn/location/pois/get_poi.json?srcids=20,21&source=appkey"
+
//改为你的微博账号,用户名和密码之间用:隔开
 +
$userPwd = 'user@sina.com:pwd';
 +
//改为你微博应用的appkey
 +
$appkey = '0123456789';
  
xml:
+
$url = "http://api.t.sina.com.cn/location/pois/get_poi.xml?srcids=test001&source=$appkey";
curl -u "username:password" "http://api.t.sina.com.cn/location/pois/get_poi.xml?srcids=20,21&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>

2011年8月11日 (四) 14:29的最后版本

目录

pois/get_poi

获取之前提交的POI信息。

URL

http://api.t.sina.com.cn/location/pois/get_poi.(json%7Cxml)

支持格式

JSON|XML

HTTP请求方式

GET

是否需要登录

true

请求参数

参数 必选 类型及范围 说明
source true string 申请应用时分配的AppKey
srcids true string 需查询来源ID(多个ID之间用“,”分割;多个ID中只要出现之前未上传的ID则无结果返回)

返回结果

XML示例

<?xml version="1.0" encoding="UTF-8" ?> 
<geoResult>
<num>2</num>
 <pois>
  <poi>
   <srcid>20</srcid>
   <name>理想国际大厦</name>
   <address>北四环西路58号</address>
   <telephone/>
   <city>北京</city>
   <category>大厦</category>
   <longitude>116.30995</longitude>
   <latitude>39.98465</latitude>
   <intro/>
   <url/>
   <tags/>
   <description/>
   <traffic/>
   <pic_url/>
   <deal>0</deal>
   <spid/>
  </poi>
  ...
</pois>
</geoResult>

JSON示例

{
 "num":2,
 "pois":
 [
  {
   "srcid":"20",
   "name":"\u7406\u60f3\u56fd\u9645\u5927\u53a6",
   "address":"\u5317\u56db\u73af\u897f\u8def58\u53f7",
   "telephone":"",
   "city":"\u5317\u4eac",
   "category":"\u5927\u53a6",
   "longitude":"116.30995",
   "latitude":"39.98465",
   "intro":"",
   "url":"",
   "tags":"",
   "description":"",
   "traffic":"",
   "pic_url":"",
   "deal":"0",
   "spid":""
  },
  ...
 ]
}

字段说明

num:结果总数
pois:结果集
srcid: POI来源id
name: POI点名称
address: POI点地址
telephone: POI点联系电话
city: POI点城市
category: POI点类别
longitude: POI点经度
latitude: POI点纬度
intro:POI点其他特色信息
url: POI点网址链接
tags: POI点标签
description: POI点介绍
traffic: POI点交通换乘描述
deal:POI的处理状态(0:未处理;1:已处理但未生成SPID;2:已处理且生成SPID;3:已发布)
spid:POI点的SPID

其它

PHP示例

需要开启PHP的cURL扩展

<?php
//改为你的微博账号,用户名和密码之间用:隔开
$userPwd = 'user@sina.com:pwd';
//改为你微博应用的appkey
$appkey = '0123456789';

$url = "http://api.t.sina.com.cn/location/pois/get_poi.xml?srcids=test001&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;
}
?>
文档更新时间: 2011-08-11