Statuses/repost

跳转到: 导航, 搜索
 
(未显示6个用户的33个中间版本)
第1行: 第1行:
== statuses/resend==
+
{{api_desc2|
转发一条微博信息。请求必须用POST方式提交。为防止重复,发布的信息与最新信息一样话,将会被忽略。
+
uri=statuses/repost|
 
+
desc=转发一条微博消息。请求必须用POST方式提交。|
=== URL===
+
format=XML/JSON|
http://api.t.sina.com.cn/statuses/resend.format
+
httpMethod=POST|
+
needAuth=true|
=== 格式===
+
rateLimit=true|
xml, json, rss, atom
+
params={{api_args|id|true|int64|要转发的微博ID}}
+
{{api_args|status|false|string|添加的转发文本。必须做URLEncode,信息内容不超过140个汉字。如不填则默认为“转发微博”。}}
=== HTTP请求方式===
+
{{api_args|is_comment|false|int|是否在转发的同时发表评论。0表示不发表评论,1表示发表评论给当前微博,2表示发表评论给原微博,3是1、2都发表。默认为0。}}|
POST
+
getParam=|
+
postParam=-d "id=4022982531&status=test repost"|
=== 是否需要登录===
+
result=
true
+
===XML示例===
+
<pre>
=== 请求数限制===
+
<?xml version="1.0" encoding="UTF-8"?>
false
+
<status>
 
+
   <created_at>Thu Dec 02 18:27:40 +0800 2010</created_at>
=== 请求参数===
+
   <id>4034439847</id>
* status.  必填参数, 添加的转发信息。必须做URLEncode,信息内容不超过140个汉字。
+
   <text>怀念一下食堂</text>
* mid  必填参数, 转发的微博ID 
+
   <source>
* iscomment 选填填参数, 是否作为一条评论发布,默认为不作为评论发布
+
    <a href="http://open.t.sina.com.cn">微博开放平台接口</a>
 
+
   </source>
=== 说明===
+
* 如果没有登录或越权发布,将返回403错误
+
* 微博将忽略重复的发布。每次发布将比较登录用户的最新一条发布消息,如果一样将被忽略。因此,用户不能连续提交相同信息。 发布成功返回发布的信息ID,否则返回为空。
+
 
+
=== 返回===
+
XML示例:
+
<?xml version="1.0" encoding="UTF-8"?>
+
<status>
+
   <created_at>Tue Apr 07 22:52:51 +0000 2009</created_at>
+
   <id>1472669360</id>
+
   <text>At least I can get your humor through tweets. RT @abdur: I don't mean this in a bad way, but genetically speaking your a cul-de-sac.</text>
+
   <source><a href="http://t.sina.com.cn/">MSN机器人</a></source>
+
   <truncated>false</truncated>
+
  <in_reply_to_status_id>1472669230</in_reply_to_status_id>
+
  <in_reply_to_user_id>10759032</in_reply_to_user_id>
+
 
   <favorited>false</favorited>
 
   <favorited>false</favorited>
   <in_reply_to_screen_name></in_reply_to_screen_name>
+
  <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>
 
   <user>
  <id>1401881</id>
+
    <id>1803880061</id>
  <name>Doug Williams</name>
+
    <screen_name>LoopB</screen_name>
  <screen_name>dougw</screen_name>
+
    <name>LoopB</name>
  <location>San Francisco, CA</location>
+
    <province>11</province>
  <description>Sina API Support. Internet, greed, users, dougw and opportunities are my passions.</description>
+
    <city>8</city>
  <url>http://www.igudo.com</url>
+
    <location>北京 海淀区</location>
  <protected>false</protected>
+
    <description/>
  <followers_count>1027</followers_count>
+
    <url/>
  <profile_background_color>9ae4e8</profile_background_color>
+
    <profile_image_url>http://tp2.sinaimg.cn/1803880061/50/0/0</profile_image_url>
  <profile_text_color>000000</profile_text_color>
+
    <domain/>
  <profile_link_color>0000ff</profile_link_color>
+
    <gender>f</gender>
  <profile_sidebar_fill_color>e0ff92</profile_sidebar_fill_color>
+
    <followers_count>2</followers_count>
  <profile_sidebar_border_color>87bc44</profile_sidebar_border_color>
+
    <friends_count>1</friends_count>
  <friends_count>293</friends_count>
+
    <statuses_count>16</statuses_count>
  <created_at>Sun Mar 18 06:42:26 +0000 2007</created_at>
+
    <favourites_count>4</favourites_count>
  <favourites_count>0</favourites_count>
+
    <created_at>Fri Aug 27 00:00:00 +0800 2010</created_at>
  <utc_offset>-18000</utc_offset>
+
    <following>false</following>
  <time_zone>Eastern Time (US & Canada)</time_zone>
+
    <verified>false</verified>
  <profile_background_tile>false</profile_background_tile>
+
    <allow_all_act_msg>false</allow_all_act_msg>
  <statuses_count>3390</statuses_count>
+
    <geo_enabled>true</geo_enabled>
  <notifications>false</notifications>
+
  <following>false</following>
+
  <verified>true</verified>
+
 
   </user>
 
   </user>
</status>
+
  <retweeted_status>
 
+
    <created_at>Thu Dec 02 18:22:41 +0800 2010</created_at>
=== 使用示例===
+
    <id>4034341063</id>
curl -u user:password -d "status=playing with cURL and resendt" http://api.t.sina.com.cn/statuses/resend.xml
+
    <text>我在学校食堂。 http://sinaurl.cn/hbhoQP</text>
 +
    <source>
 +
      <a href="http://jiepang.com/?utm_source=weibo&amp;utm_medium=social&amp;utm_content=record_share&amp;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>
 +
</pre>
 +
===JSON示例===
 +
<pre>
 +
{
 +
    "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>"
 +
}
 +
</pre>|
 +
useAge=
 +
* 为防止重复提交,当用户发布的微博消息与上次成功发布的微博消息内容一样时,将返回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"|
 +
otherInfo=
 +
===PHP示例===
 +
请从 [[SDK | 微博SDK开发包下载]] 处下载PHP SDK(支持OAuth验证之版本)<br>
 +
代码示例如下:
 +
<pre>
 +
//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']);
 +
}
 +
</pre>
 +
}}

2012年9月24日 (一) 11:37的最后版本

目录

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。

注意事项

返回结果

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