Statuses/repost
目录 |
statuses/repost
转发一条微博消息。请求必须用POST方式提交。
URL
http://api.t.sina.com.cn/statuses/repost.(json%7Cxml)
支持格式
XML/JSON
HTTP请求方式
POST
是否需要登录
true
关于授权机制,参见授权机制声明
请求数限制
true
关于请求数限制,参见接口访问权限说明
请求参数
| 必选 | 类型及范围 | 说明 | |
|---|---|---|---|
| source | true | string | 申请应用时分配的AppKey,调用接口时候代表应用的唯一身份。(采用OAuth授权方式不需要此参数) |
| id | true | int64 | 要转发的微博ID |
| status | false | string | 添加的转发文本。必须做URLEncode,信息内容不超过140个汉字。如不填则默认为“转发微博”。 |
| is_comment | false | int | 是否在转发的同时发表评论。0表示不发表评论,1表示发表评论给当前微博,2表示发表评论给原微博,3是1、2都发表。默认为0。 |
注意事项
- 为防止重复提交,当用户发布的微博消息与上次成功发布的微博消息内容一样时,将返回400错误。
- 为了与部分老版本的SDK兼容,该接口还有另外一种调用方式:
- http://api.t.sina.com.cn/statuses/retweet/:id.format
- 其中,:id参数以REST风格的形式出现,表示要转发的微博消息ID。
- CURL示例如下:
- curl -u "username:password" -d "status=repost_test&source=appkey" "http://api.t.sina.com.cn/statuses/retweet/4022982531.xml"
返回结果
XML示例
<?xml version="1.0" encoding="UTF-8"?>
<status>
<created_at>Thu Dec 02 18:27:40 +0800 2010</created_at>
<id>4034439847</id>
<text>怀念一下食堂</text>
<source>
<a href="http://open.t.sina.com.cn">微博开放平台接口</a>
</source>
<favorited>false</favorited>
<truncated>false</truncated>
<geo/>
<in_reply_to_status_id>4034341063</in_reply_to_status_id>
<in_reply_to_user_id>1312425275</in_reply_to_user_id>
<in_reply_to_screen_name>莓控控</in_reply_to_screen_name>
<user>
<id>1803880061</id>
<screen_name>LoopB</screen_name>
<name>LoopB</name>
<province>11</province>
<city>8</city>
<location>北京 海淀区</location>
<description/>
<url/>
<profile_image_url>http://tp2.sinaimg.cn/1803880061/50/0/0</profile_image_url>
<domain/>
<gender>f</gender>
<followers_count>2</followers_count>
<friends_count>1</friends_count>
<statuses_count>16</statuses_count>
<favourites_count>4</favourites_count>
<created_at>Fri Aug 27 00:00:00 +0800 2010</created_at>
<following>false</following>
<verified>false</verified>
<allow_all_act_msg>false</allow_all_act_msg>
<geo_enabled>true</geo_enabled>
</user>
<retweeted_status>
<created_at>Thu Dec 02 18:22:41 +0800 2010</created_at>
<id>4034341063</id>
<text>我在学校食堂。 http://sinaurl.cn/hbhoQP</text>
<source>
<a href="http://jiepang.com/?utm_source=weibo&utm_medium=social&utm_content=record_share&utm_campaign=appname_link">街旁网分享足迹</a>
</source>
<favorited>false</favorited>
<truncated>false</truncated>
<geo xmlns:georss="http://www.georss.org/georss">
<georss:point>38.882116 115.576611</georss:point>
</geo>
<in_reply_to_status_id/>
<in_reply_to_user_id/>
<in_reply_to_screen_name/>
<user>
<id>1312425275</id>
<screen_name>莓控控</screen_name>
<name>莓控控</name>
<province>13</province>
<city>6</city>
<location>河北 保定</location>
<description>明年的今天?我会拥有9300吗?</description>
<url>http://1</url>
<profile_image_url>http://tp4.sinaimg.cn/1312425275/50/1288322957</profile_image_url>
<domain>mikkforever</domain>
<gender>m</gender>
<followers_count>184</followers_count>
<friends_count>133</friends_count>
<statuses_count>528</statuses_count>
<favourites_count>17</favourites_count>
<created_at>Mon Jul 05 00:00:00 +0800 2010</created_at>
<following>false</following>
<verified>false</verified>
<allow_all_act_msg>true</allow_all_act_msg>
<geo_enabled>true</geo_enabled>
</user>
</retweeted_status>
</status>
JSON示例
{
"created_at" : "Thu Dec 02 18:33:58 +0800 2010",
"text" : "zhuanfa",
"truncated" : false,
"retweeted_status" :
{
"created_at" : "Thu Dec 02 18:29:30 +0800 2010",
"text" : "zhuanfa",
"truncated" : false,
"in_reply_to_status_id" : "",
"in_reply_to_screen_name" : "",
"geo" : null,
"user" :
{
"name" : "LoopB",
"domain" : "",
"geo_enabled" : true,
"followers_count" : 2,
"statuses_count" : 19,
"favourites_count" : 4,
"city" : "8",
"description" : "",
"verified" : false,
"id" : 1803880061,
"gender" : "f",
"friends_count" : 1,
"screen_name" : "LoopB",
"allow_all_act_msg" : false,
"following" : false,
"url" : "",
"profile_image_url" : "http://tp2.sinaimg.cn/1803880061/50/0/0",
"created_at" : "Fri Aug 27 00:00:00 +0800 2010",
"province" : "11",
"location" : "北京 海淀区"
},
"favorited" : false,
"in_reply_to_user_id" : "",
"id" : 4034476951,
"source" : "<a href=\"\" rel=\"nofollow\">微博开放平台接口</a>"
},
"in_reply_to_status_id" : "4034476951",
"in_reply_to_screen_name" : "LoopB",
"geo" : null,
"user" :
{
"name" : "LoopB",
"domain" : "",
"geo_enabled" : true,
"followers_count" : 2,
"statuses_count" : 20,
"favourites_count" : 4,
"city" : "8",
"description" : "",
"verified" : false,
"id" : 1803880061,
"gender" : "f",
"friends_count" : 1,
"screen_name" : "LoopB",
"allow_all_act_msg" : false,
"following" : false,
"url" : "",
"profile_image_url" : "http://tp2.sinaimg.cn/1803880061/50/0/0",
"created_at" : "Fri Aug 27 00:00:00 +0800 2010",
"province" : "11",
"location" : "北京 海淀区"
},
"favorited" : false,
"in_reply_to_user_id" : "1803880061",
"id" : 4034567627,
"source" : "<a href=\"http://open.t.sina.com.cn\" rel=\"nofollow\">微博开放平台接口</a>"
}
其他
PHP示例
请从 微博SDK开发包下载 处下载PHP SDK(支持OAuth验证之版本)
代码示例如下:
//Statuses/repost
$c = new WeiboClient( WB_AKEY ,
WB_SKEY ,
$_SESSION['last_key']['oauth_token'] ,
$_SESSION['last_key']['oauth_token_secret'] );
$msg = $c->user_timeline();
if ($msg === false || $msg === null){
echo "Error occured";
return false;
}
if (count($msg)> 1){
$sid = $msg[1]['id'];
echo($sid);
$msg = $c->repost($sid);
if ($msg === false || $msg === null){
echo "Error occured";
return false;
}
echo($msg['id'].' : '.$msg['text']);
}
文档更新时间: 2012-09-24