Statuses/destroy

跳转到: 导航, 搜索
(请求数限制)
 
(未显示5个用户的15个中间版本)
第1行: 第1行:
== statuses/destroy ==
+
{{api_desc2|
删除微博。注意:只能删除自己发布的信息。
+
uri=statuses/destroy/:id|
 
+
desc=根据ID删除微博消息。注意:只能删除自己发布的微博消息。 |
=== URL===
+
format=XML/JSON|
curl http://api.t.sina.com.cn/statuses/destroy/id.format
+
httpMethod=POST/DELETE|
 +
needAuth=true|
 +
rateLimit=true|
 +
params={{api_args|:id|true|int64|要删除的微博消息ID}}|
 +
getParam=|
 +
postParam=-X DELETE|
 +
result=
 +
===XML示例===
 +
<pre>
 +
<?xml version="1.0" encoding="UTF-8"?>
 +
<status>
 +
  <created_at>Thu Dec 02 15:09:11 +0800 2010</created_at>
 +
  <id>4020772979</id>
 +
  <text>fTW9YwY</text>
 +
  <source>
 +
    <a href="">微博开放平台接口</a>
 +
  </source>
 +
  <favorited>false</favorited>
 +
  <truncated>false</truncated>
 +
  <geo/>
 +
  <in_reply_to_status_id/>
 +
  <in_reply_to_user_id/>
 +
  <in_reply_to_screen_name/>
 +
  <user>
 +
    <id>1803876591</id>
 +
    <screen_name>loopa</screen_name>
 +
    <name>loopa</name>
 +
    <province>11</province>
 +
    <city>8</city>
 +
    <location>北京 海淀区</location>
 +
    <description>AnRHJLCc9Ac0fCY</description>
 +
    <url/>
 +
    <profile_image_url>http://tp4.sinaimg.cn/1803876591/50/0/1</profile_image_url>
 +
    <domain/>
 +
    <gender>m</gender>
 +
    <followers_count>28</followers_count>
 +
    <friends_count>2</friends_count>
 +
    <statuses_count>13714</statuses_count>
 +
    <favourites_count>1</favourites_count>
 +
    <created_at>Wed Dec 01 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>
 +
</status>
 +
</pre>
 +
===JSON示例===
 +
<pre>
 +
{
 +
    "created_at" : "Thu Dec 02 14:22:35 +0800 2010",
 +
    "text" : "CT7rM6v",
 +
    "truncated" : false,
 +
    "in_reply_to_status_id" : "",
 +
    "in_reply_to_screen_name" : "",
 +
    "geo" : null,
 +
    "user" :
 +
    {
 +
        "name" : "loopa",
 +
        "domain" : "",
 +
        "geo_enabled" : true,
 +
        "followers_count" : 28,
 +
        "statuses_count" : 13715,
 +
        "favourites_count" : 1,
 +
        "city" : "8",
 +
        "description" : "4mcJW0EhJiU1GwN",
 +
        "verified" : false,
 +
        "id" : 1803876591,
 +
        "gender" : "m",
 +
        "friends_count" : 2,
 +
        "screen_name" : "loopa",
 +
        "allow_all_act_msg" : false,
 +
        "following" : false,
 +
        "url" : "",
 +
        "profile_image_url" : "http://tp4.sinaimg.cn/1803876591/50/0/1",
 +
        "created_at" : "Wed Dec 01 00:00:00 +0800 2010",
 +
        "province" : "11",
 +
        "location" : "北京 海淀区"
 +
    },
 +
    "favorited" : false,
 +
    "in_reply_to_user_id" : "",
 +
    "id" : 4019894325,
 +
    "source" : "<a href=\"\" rel=\"nofollow\">微博开放平台接口</a>"
 +
}
 +
</pre>|
 +
useAge=如果参数错误,将返回400错误|
 +
otherInfo=
 +
===Java示例===
 +
请从 [[SDK | 微博SDK开发包下载]] 下载Java SDK<br>
 +
代码示意如下:
 +
package weibo4j.examples;
 
   
 
   
=== 格式===
+
import java.util.List;
xml, json
+
import weibo4j.Status;
 +
import weibo4j.Weibo;
 
   
 
   
=== HTTP请求方式===
+
public class DeleteStatus {
POST, DELETE
+
 
   
 
   
=== 是否需要身份验证===
+
/**
true
+
* 删除一条微博信息
 +
* @param args
 +
*/
 +
public static void main(String[] args) {
 +
System.setProperty("weibo4j.oauth.consumerKey", Weibo.CONSUMER_KEY);
 +
    System.setProperty("weibo4j.oauth.consumerSecret", Weibo.CONSUMER_SECRET);
 +
        try {
 +
        Weibo weibo = getWeibo(true,args);
 +
        //先发表一篇微博
 +
        Status status = weibo.updateStatus("测试测试");
 +
        System.out.println(status.getId() + " : "+ status.getText()+"  "+status.getCreatedAt());
 +
        //删除刚发表的微博
 +
        status = weibo.destroyStatus(status.getId());
 +
        List<Status> list = weibo.getUserTimeline(args[2]);//args[2]:用户id
 +
        for(Status st : list) {//遍历当前微博信息
 +
        System.out.println(st.getId() + " : "+ st.getText()+"  "+st.getCreatedAt());
 +
        }
 +
} catch (Exception e) {
 +
e.printStackTrace();
 +
}
 +
}
 
   
 
   
=== 请求数限制===
+
private static Weibo getWeibo(boolean isOauth,String ... args) {
true
+
Weibo weibo = new Weibo();
 
+
if(isOauth) {//oauth验证方式 args[0]:访问的token;args[1]:访问的密匙
=== 请求参数===
+
  weibo.setToken(args[0], args[1]);
* id. 必须参数. 要删除的微博ID.  
+
}else {//用户登录方式
o 示例: http://api.t.sina.com.cn/statuses/destroy/12345.xml
+
    weibo.setUserId(args[0]);//用户名/ID
 
+
    weibo.setPassword(args[1]);//密码
=== 使用说明===
+
}
* 如果参数错误,将返回500错误
+
return weibo;
 
+
}
=== 返回结果 ===
+
}
XML示例:
+
===PHP示例===
<?xml version="1.0" encoding="UTF-8"?>
+
请从 [[SDK | 微博SDK开发包下载]] 处下载PHP SDK(支持OAuth验证之版本)<br>  
  <status>
+
代码示例如下:
    <created_at>Thu Jan 07 18:26:53 +0800 2010</created_at>
+
<pre>
    <id>142311</id>
+
//Statuses/destroy
    <text>lsdjfl端口</text>
+
$c = new WeiboClient( WB_AKEY ,  
    <source>
+
                      WB_SKEY ,  
      <a id="10013" href="http://t.sina.com.cn">SinaDestTop</a>
+
                      $_SESSION['last_key']['oauth_token'] ,  
    </source>
+
                      $_SESSION['last_key']['oauth_token_secret']  );
    <favorited>false</favorited>
+
//先发表一篇微博
    <truncated>false</truncated>
+
$msg = $c->update("测试发表微博");
    <geo/>
+
if ($msg === false || $msg === null){
    <in_reply_to_status_id></in_reply_to_status_id>
+
echo "Error occured";
    <in_reply_to_user_id></in_reply_to_user_id>
+
return false;
    <in_reply_to_screen_name></in_reply_to_screen_name>
+
}
    <user>
+
if (isset($msg['error_code']) && isset($msg['error'])){
      <id>11075</id>
+
echo ('Error_code: '.$msg['error_code'].';  Error: '.$msg['error'] );
      <screen_name>name_11075</screen_name>
+
return false;
      <name>name_11075</name>
+
}
      <province>0</province>
+
echo($msg['id']." : ".$msg['text']." ".$msg["created_at"]);
      <city>0</city>
+
//删除刚发表的微博
      <location></location>
+
$c->destroy($msg['id']);
      <description></description>
+
if ($msg === false || $msg === null){
      <profile_image_url>http://tp4.sinaimg.cn/11075/50/0</profile_image_url>
+
echo "Error occured";
      <domain>11075</domain>
+
return false;
      <gender></gender>
+
}
      <email></email>
+
if (isset($msg['error_code']) && isset($msg['error'])){
      <qq>4102</qq>
+
echo ('Error_code: '.$msg['error_code'].';  Error: '.$msg['error'] );
      <msn>msn_4102</msn>
+
return false;
      <followers_count>28</followers_count>
+
}
      <friends_count>50</friends_count>
+
//user id
      <statuses_count>0</statuses_count>
+
$uid = "User ID";
      <favourites_count>33</favourites_count>
+
$msg = $c->user_timeline($uid);
      <created_at>Thu Jan 01 08:00:00 +0800 1970</created_at>
+
if ($msg === false || $msg === null){
      <following>false</following>
+
echo "Error occured";
      <verified>true</verified>
+
return false;
      <geo_enabled>false</geo_enabled>
+
}
    </user>
+
if (isset($msg['error_code']) && isset($msg['error'])){
  </status>
+
echo ('Error_code: '.$msg['error_code'].';  Error: '.$msg['error'] );
 
+
return false;
JSON示例:
+
}
 
+
//遍历当前微博信息
  {"created_at":"Thu Jan 07 18:27:35 +0800 2010",
+
foreach($msg as $data){
    "id":142312,
+
echo($data['id']." : ".$data['text']." ".$data["created_at"]);
    "text":"lsdjfl端口",
+
}
    "source":"<a id=\"10013\" href=\"http://t.sina.com.cn/\" rel=\"nofollow\">SinaDestTop</a>",
+
</pre>
    "favorited":false,
+
}}
    "truncated":false,
+
    "in_reply_to_status_id":"",
+
    "in_reply_to_user_id":"",
+
    "in_reply_to_screen_name":"",
+
    "geo":null,
+
    "user":
+
          {"id":11075,
+
          "screen_name":"name_11075",
+
          "name":"name_11075",
+
          "province":"0",
+
          "city":"0",
+
          "location":"",
+
          "description":"",
+
          "profile_image_url":"http://tp4.sinaimg.cn/11075/50/0",
+
          "domain":"11075",
+
          "email":"",
+
          "qq":"4102",
+
          "msn":"msn_4102",
+
          "followers_count":28,
+
          "friends_count":50,
+
          "statuses_count":0,
+
          "favourites_count":34,
+
          "created_at":"Thu Jan 01 08:00:00 +0800 1970",
+
          "following":false,
+
          "geo_enabled":false,
+
          "verified":true},
+
    "apiState":3
+
  }
+
 
+
=== 使用示例===
+
 
+
* xml:
+
 
+
curl -u user:password --http-request DELETE http://api.t.sina.com.cn/statuses/destroy/1472669360.xml
+
 
+
* json:
+
 
+
curl -u user:password --http-request DELETE http://api.t.sina.com.cn/statuses/destroy/1472669360.json
+

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

目录

statuses/destroy/:id

根据ID删除微博消息。注意:只能删除自己发布的微博消息。

URL

http://api.t.sina.com.cn/statuses/destroy/:id.(json%7Cxml)

支持格式

XML/JSON

HTTP请求方式

POST/DELETE

是否需要登录

true
关于授权机制,参见授权机制声明

请求数限制

true
关于请求数限制,参见接口访问权限说明

请求参数

  必选 类型及范围 说明
source true string 申请应用时分配的AppKey,调用接口时候代表应用的唯一身份。(采用OAuth授权方式不需要此参数)
:id true int64 要删除的微博消息ID

注意事项

如果参数错误,将返回400错误

返回结果

XML示例

<?xml version="1.0" encoding="UTF-8"?>
<status>
  <created_at>Thu Dec 02 15:09:11 +0800 2010</created_at>
  <id>4020772979</id>
  <text>fTW9YwY</text>
  <source>
    <a href="">微博开放平台接口</a>
  </source>
  <favorited>false</favorited>
  <truncated>false</truncated>
  <geo/>
  <in_reply_to_status_id/>
  <in_reply_to_user_id/>
  <in_reply_to_screen_name/>
  <user>
    <id>1803876591</id>
    <screen_name>loopa</screen_name>
    <name>loopa</name>
    <province>11</province>
    <city>8</city>
    <location>北京 海淀区</location>
    <description>AnRHJLCc9Ac0fCY</description>
    <url/>
    <profile_image_url>http://tp4.sinaimg.cn/1803876591/50/0/1</profile_image_url>
    <domain/>
    <gender>m</gender>
    <followers_count>28</followers_count>
    <friends_count>2</friends_count>
    <statuses_count>13714</statuses_count>
    <favourites_count>1</favourites_count>
    <created_at>Wed Dec 01 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>
</status>

JSON示例

{
    "created_at" : "Thu Dec 02 14:22:35 +0800 2010",
    "text" : "CT7rM6v",
    "truncated" : false,
    "in_reply_to_status_id" : "",
    "in_reply_to_screen_name" : "",
    "geo" : null,
    "user" : 
    {
        "name" : "loopa",
        "domain" : "",
        "geo_enabled" : true,
        "followers_count" : 28,
        "statuses_count" : 13715,
        "favourites_count" : 1,
        "city" : "8",
        "description" : "4mcJW0EhJiU1GwN",
        "verified" : false,
        "id" : 1803876591,
        "gender" : "m",
        "friends_count" : 2,
        "screen_name" : "loopa",
        "allow_all_act_msg" : false,
        "following" : false,
        "url" : "",
        "profile_image_url" : "http://tp4.sinaimg.cn/1803876591/50/0/1",
        "created_at" : "Wed Dec 01 00:00:00 +0800 2010",
        "province" : "11",
        "location" : "北京 海淀区"
    },
    "favorited" : false,
    "in_reply_to_user_id" : "",
    "id" : 4019894325,
    "source" : "<a href=\"\" rel=\"nofollow\">微博开放平台接口</a>"
}

其他

Java示例

请从 微博SDK开发包下载 下载Java SDK
代码示意如下:

package weibo4j.examples;

import java.util.List;
import weibo4j.Status;
import weibo4j.Weibo;

public class DeleteStatus {

	/**
	 * 删除一条微博信息
	 * @param args
	 */
	public static void main(String[] args) {
		System.setProperty("weibo4j.oauth.consumerKey", Weibo.CONSUMER_KEY);
    	System.setProperty("weibo4j.oauth.consumerSecret", Weibo.CONSUMER_SECRET);
       try {
        	Weibo weibo = getWeibo(true,args);
       	//先发表一篇微博
       	Status status = weibo.updateStatus("测试测试");
       	System.out.println(status.getId() + " : "+ status.getText()+"  "+status.getCreatedAt());
       	//删除刚发表的微博
       	status = weibo.destroyStatus(status.getId());
       	List<Status> list = weibo.getUserTimeline(args[2]);//args[2]:用户id
       	for(Status st : list) {//遍历当前微博信息
       		System.out.println(st.getId() + " : "+ st.getText()+"  "+st.getCreatedAt());
       	}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static Weibo getWeibo(boolean isOauth,String ... args) {
		Weibo weibo = new Weibo();
		if(isOauth) {//oauth验证方式 args[0]:访问的token;args[1]:访问的密匙
 			weibo.setToken(args[0], args[1]);
		}else {//用户登录方式
   		weibo.setUserId(args[0]);//用户名/ID
   		weibo.setPassword(args[1]);//密码
		}
		return weibo;
	}
}

PHP示例

请从 微博SDK开发包下载 处下载PHP SDK(支持OAuth验证之版本)
代码示例如下:

//Statuses/destroy
$c = new WeiboClient( WB_AKEY , 
                      WB_SKEY , 
                      $_SESSION['last_key']['oauth_token'] , 
                      $_SESSION['last_key']['oauth_token_secret']  );
//先发表一篇微博
$msg = $c->update("测试发表微博");
if ($msg === false || $msg === null){
	echo "Error occured";
	return false;
}
if (isset($msg['error_code']) && isset($msg['error'])){
	echo ('Error_code: '.$msg['error_code'].';  Error: '.$msg['error'] );
	return false;
} 
echo($msg['id']." : ".$msg['text']." ".$msg["created_at"]);
//删除刚发表的微博
$c->destroy($msg['id']);
if ($msg === false || $msg === null){
	echo "Error occured";
	return false;
}
if (isset($msg['error_code']) && isset($msg['error'])){
	echo ('Error_code: '.$msg['error_code'].';  Error: '.$msg['error'] );
	return false;
}
//user id
$uid = "User ID";
$msg = $c->user_timeline($uid);
if ($msg === false || $msg === null){
	echo "Error occured";
	return false;
}
if (isset($msg['error_code']) && isset($msg['error'])){
	echo ('Error_code: '.$msg['error_code'].';  Error: '.$msg['error'] );
	return false;
} 
//遍历当前微博信息
foreach($msg as $data){
	echo($data['id']." : ".$data['text']." ".$data["created_at"]);
}
文档更新时间: 2012-09-24