Statuses/repost

跳转到: 导航, 搜索
(PHP示例)
 
(未显示3个用户的11个中间版本)
第1行: 第1行:
== statuses/repost==
+
{{api_desc2|
转发一条微博信息。请求必须用POST方式提交。为防止重复,发布的信息与最新信息一样话,将会被忽略。
+
uri=statuses/repost|
 
+
desc=转发一条微博消息。请求必须用POST方式提交。|
=== URL===
+
format=XML/JSON|
http://api.t.sina.com.cn/statuses/repost.format
+
httpMethod=POST|
or
+
needAuth=true|
http://api.t.sina.com.cn/statuses/retweet/id.format
+
rateLimit=true|
+
params={{api_args|id|true|int64|要转发的微博ID}}
=== 格式===
+
{{api_args|status|false|string|添加的转发文本。必须做URLEncode,信息内容不超过140个汉字。如不填则默认为“转发微博”。}}
xml, json
+
{{api_args|is_comment|false|int|是否在转发的同时发表评论。0表示不发表评论,1表示发表评论给当前微博,2表示发表评论给原微博,3是1、2都发表。默认为0。}}|
+
getParam=|
=== HTTP请求方式===
+
postParam=-d "id=4022982531&status=test repost"|
POST
+
result=
+
===XML示例===
=== 是否需要登录===
+
<pre>
true
+
<?xml version="1.0" encoding="UTF-8"?>
+
<status>
=== 请求数限制===
+
  <created_at>Thu Dec 02 18:27:40 +0800 2010</created_at>
true
+
  <id>4034439847</id>
 
+
  <text>怀念一下食堂</text>
=== 请求参数===
+
  <source>
* id  必填参数, 转发的微博ID 
+
    <a href="http://open.t.sina.com.cn">微博开放平台接口</a>
* status.  可选参数, 添加的转发信息。必须做URLEncode,信息内容不超过140个汉字。如不填则自动生成类似“转发 @author: 原内容”文字。
+
  </source>
 
+
  <favorited>false</favorited>
=== 使用说明===
+
  <truncated>false</truncated>
* 如果没有登录,将返回403错误
+
  <geo/>
* 转发的微博不存在,将返回500错误
+
  <in_reply_to_status_id>4034341063</in_reply_to_status_id>
* 微博将忽略重复的发布。每次发布将比较登录用户的最新一条发布消息,如果一样将被忽略。因此,用户不能连续提交相同信息。 发布成功返回发布的信息ID,否则返回为空。
+
  <in_reply_to_user_id>1312425275</in_reply_to_user_id>
 
+
  <in_reply_to_screen_name>莓控控</in_reply_to_screen_name>
=== 返回结果===
+
  <user>
XML示例:
+
    <id>1803880061</id>
<?xml version="1.0" encoding="UTF-8"?>
+
    <screen_name>LoopB</screen_name>
<status>
+
    <name>LoopB</name>
     <created_at>Tue Dec 01 08:51:58 +0800 2009</created_at>
+
    <province>11</province>
     <id>99999999</id>
+
    <city>8</city>
     <text>转发:@1141457724 </text>
+
    <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>
 
     <source>
       <a href="http://t.sina.com.cn">Web</a>
+
       <a href="http://jiepang.com/?utm_source=weibo&amp;utm_medium=social&amp;utm_content=record_share&amp;utm_campaign=appname_link">街旁网分享足迹</a>
 
     </source>
 
     </source>
 
     <favorited>false</favorited>
 
     <favorited>false</favorited>
 
     <truncated>false</truncated>
 
     <truncated>false</truncated>
     <in_reply_to_status_id></in_reply_to_status_id>
+
     <geo xmlns:georss="http://www.georss.org/georss">
     <in_reply_to_user_id></in_reply_to_user_id>
+
      <georss:point>38.882116 115.576611</georss:point>
     <in_reply_to_screen_name></in_reply_to_screen_name>
+
     </geo>
 +
    <in_reply_to_status_id/>
 +
     <in_reply_to_user_id/>
 +
    <in_reply_to_screen_name/>
 
     <user>
 
     <user>
       <id>1141457724</id>
+
       <id>1312425275</id>
       <screen_name>1141457724</screen_name>
+
       <screen_name>莓控控</screen_name>
       <name>1141457724</name>
+
       <name>莓控控</name>
       <location>广州</location>
+
      <province>13</province>
       <description>blog: timyang.net</description>
+
      <city>6</city>
       <url>http://timyang.net</url>
+
       <location>河北 保定</location>
       <profile_image_url>http://portrait.sinaimg.cn/1141457724/50#.jpg</profile_image_url>
+
       <description>明年的今天?我会拥有9300吗?</description>
       <followers_count>0</followers_count>
+
       <url>http://1</url>
       <friends_count>0</friends_count>
+
       <profile_image_url>http://tp4.sinaimg.cn/1312425275/50/1288322957</profile_image_url>
       <statuses_count>0</statuses_count>
+
      <domain>mikkforever</domain>
       <favourites_count>0</favourites_count>
+
      <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>
 
       <following>false</following>
 +
      <verified>false</verified>
 +
      <allow_all_act_msg>true</allow_all_act_msg>
 +
      <geo_enabled>true</geo_enabled>
 
     </user>
 
     </user>
    <retweeted_status>
+
  </retweeted_status>
      <created_at>Tue Dec 01 08:51:58 +0800 2009</created_at>
+
</status>
      <id>100000000</id>
+
</pre>
      <text>虽然渴者只要少许的水便够了,我却很快活地给与了我全部的水。</text>
+
===JSON示例===
      <source>
+
<pre>
        <a href="http://t.sina.com.cn">Web</a>
+
{
      </source>
+
     "created_at" : "Thu Dec 02 18:33:58 +0800 2010",
      <favorited>false</favorited>
+
     "text" : "zhuanfa",
      <truncated>false</truncated>
+
     "truncated" : false,
      <in_reply_to_status_id></in_reply_to_status_id>
+
     "retweeted_status" :  
      <in_reply_to_user_id></in_reply_to_user_id>
+
    {
      <in_reply_to_screen_name></in_reply_to_screen_name>
+
        "created_at" : "Thu Dec 02 18:29:30 +0800 2010",
      <thumbnail_pic>http://static16.photo.sina.com.cn/thumbnail/62988d06tcbbc377f7bbf</thumbnail_pic>
+
        "text" : "zhuanfa",
      <bmiddle_pic>http://static16.photo.sina.com.cn/bmiddle/62988d06tcbbc377f7bbf</bmiddle_pic>
+
        "truncated" : false,
      <original_pic>http://static16.photo.sina.com.cn/orignal/62988d06tcbbc377f7bbf</original_pic>
+
        "in_reply_to_status_id" : "",
      <user>
+
        "in_reply_to_screen_name" : "",
        <id>1337040644</id>
+
        "geo" : null,
        <screen_name>1337040644</screen_name>
+
        "user" :  
        <name>1337040644</name>
+
        {
        <location>广州</location>
+
            "name" : "LoopB",
        <description>blog: timyang.net</description>
+
            "domain" : "",
        <url>http://timyang.net</url>
+
            "geo_enabled" : true,
        <profile_image_url>http://portrait.sinaimg.cn/1337040644/50#.jpg</profile_image_url>
+
            "followers_count" : 2,
        <followers_count>0</followers_count>
+
            "statuses_count" : 19,
        <friends_count>0</friends_count>
+
            "favourites_count" : 4,
        <statuses_count>0</statuses_count>
+
            "city" : "8",
        <favourites_count>0</favourites_count>
+
            "description" : "",
        <following>false</following>
+
            "verified" : false,
      </user>
+
            "id" : 1803880061,
     </retweeted_status>
+
            "gender" : "f",
  </status>
+
            "friends_count" : 1,
 
+
            "screen_name" : "LoopB",
JSON示例:
+
            "allow_all_act_msg" : false,
 
+
            "following" : false,
    {"created_at":"Thu Jan 07 10:07:45 +0800 2010",
+
            "url" : "",
     "id":142284,
+
            "profile_image_url" : "http://tp2.sinaimg.cn/1803880061/50/0/0",
     "text":"111111111111111111",
+
            "created_at" : "Fri Aug 27 00:00:00 +0800 2010",
     "source":"<a id=\"0\" href=\"http://t.sina.com.cn/\" rel=\"nofollow\">Web</a>",
+
            "province" : "11",
    "favorited":false,
+
            "location" : "北京 海淀区"
    "truncated":false,
+
        },
    "in_reply_to_status_id":"142281",
+
        "favorited" : false,
    "in_reply_to_user_id":"11046",
+
        "in_reply_to_user_id" : "",
    "in_reply_to_screen_name":"name_11046",
+
        "id" : 4034476951,
    "geo":null,
+
        "source" : "<a href=\"\" rel=\"nofollow\">微博开放平台接口</a>"
    "user":<br/>        {"id":11075,
+
    },
        "screen_name":"name_11075",
+
    "in_reply_to_status_id" : "4034476951",
        "name":"name_11075",
+
    "in_reply_to_screen_name" : "LoopB",
        "province":"0",
+
    "geo" : null,
        "city":"0",
+
    "user" :
        "location":"",
+
    {
        "description":"",
+
        "name" : "LoopB",
        "url":"",
+
        "domain" : "",
        "profile_image_url":"http://tp4.sinaimg.cn/11075/50/0",
+
        "geo_enabled" : true,
        "domain":"11075",
+
        "followers_count" : 2,
        "followers_count":28,
+
        "statuses_count" : 20,
        "friends_count":50,
+
        "favourites_count" : 4,
        "statuses_count":0,
+
        "city" : "8",
        "favourites_count":27,
+
        "description" : "",
        "created_at":"Thu Jan 01 08:00:00 +0800 1970",
+
        "verified" : false,
        "following":false,
+
        "id" : 1803880061,
        "geo_enabled":false,
+
        "gender" : "f",
        "verified":true},
+
        "friends_count" : 1,
    "retweeted_status":<br/>        {"created_at":"Thu Jan 07 09:54:49 +0800 2010",
+
        "screen_name" : "LoopB",
        "id":142281,
+
        "allow_all_act_msg" : false,
        "text":"测试test",
+
        "following" : false,
        "source":"<a id=\"0\" href=\"http://t.sina.com.cn/\" rel=\"nofollow\">Web</a>",
+
        "url" : "",
        "favorited":false,
+
        "profile_image_url" : "http://tp2.sinaimg.cn/1803880061/50/0/0",
        "truncated":false,
+
        "created_at" : "Fri Aug 27 00:00:00 +0800 2010",
        "in_reply_to_status_id":"",
+
        "province" : "11",
        "in_reply_to_user_id":"",
+
        "location" : "北京 海淀区"
        "in_reply_to_screen_name":"",
+
    },
        "geo":null,
+
    "favorited" : false,
        "user":<br/>            {"id":11046,
+
    "in_reply_to_user_id" : "1803880061",
              "screen_name":"name_11046",
+
    "id" : 4034567627,
              "name":"name_11046",
+
    "source" : "<a href=\"http://open.t.sina.com.cn\" rel=\"nofollow\">微博开放平台接口</a>"
              "province":"0",
+
}
              "city":"0",
+
</pre>|
              "location":"",
+
useAge=
              "description":"",
+
* 为防止重复提交,当用户发布的微博消息与上次成功发布的微博消息内容一样时,将返回400错误。
              "url":"",
+
* 为了与部分老版本的SDK兼容,该接口还有另外一种调用方式:
              "profile_image_url":"http://tp3.sinaimg.cn/11046/50/0",
+
* http://api.t.sina.com.cn/statuses/retweet/:id.format
              "domain":"11046",
+
* 其中,:id参数以REST风格的形式出现,表示要转发的微博消息ID。
              "followers_count":37,
+
* CURL示例如下:
              "friends_count":50,
+
* curl -u "username:password" -d "status=repost_test&source=appkey" "http://api.t.sina.com.cn/statuses/retweet/4022982531.xml"|
              "statuses_count":0,
+
otherInfo=
              "favourites_count":0,
+
===PHP示例===
              "created_at":"Thu Jan 01 08:00:00 +0800 1970",
+
              "following":false,
+
              "geo_enabled":false,
+
              "verified":false}
+
        }
+
    }
+
 
+
=== 使用示例===
+
 
+
* xml:
+
curl -u uid:password -d "source=appkey&id=1&status=playing with cURL and repost" http://api.t.sina.com.cn/statuses/repost.xml
+
 
+
* json:
+
curl -u uid:password -d "source=appkey&id=1&status=playing with cURL and repost" http://api.t.sina.com.cn/statuses/repost.json
+
====PHP示例====
+
 
请从 [[SDK | 微博SDK开发包下载]] 处下载PHP SDK(支持OAuth验证之版本)<br>  
 
请从 [[SDK | 微博SDK开发包下载]] 处下载PHP SDK(支持OAuth验证之版本)<br>  
 
代码示例如下:
 
代码示例如下:
第182行: 第197行:
 
}
 
}
 
</pre>
 
</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