Friendships/destroy
(→返回结果) |
|||
(未显示3个用户的14个中间版本) | |||
第1行: | 第1行: | ||
− | + | {{api_desc2| | |
− | + | uri=friendships/destroy| | |
− | + | desc=取消对某用户的关注。| | |
− | = | + | format=XML/JSON| |
− | + | httpMethod=POST/DELETE| | |
− | + | needAuth=true| | |
− | + | rateLimit=true| | |
− | + | params={{api_args|:id|false|int64/string|要取消关注的用户ID(int64)或者微博昵称(string),该参数是一个REST风格的参数。用法见注意事项}} | |
− | + | {{api_args|user_id|false|int64|要取消关注的用户ID,为了避免用户的ID与微博昵称相同而产生混淆的情况,推荐使用该参数。}} | |
− | = | + | {{api_args|screen_name|false|string|要取消关注的用户微博昵称,为了避免用户的ID与微博昵称相同而产生混淆的情况,推荐使用该参数。}} |
− | POST | + | {{api_args_colspan|1=<font style="color:#ee3333">:id、user_id、screen_name这三个参数必填其一。</font>}}| |
− | + | getParam=| | |
− | = | + | postParam=-d "user_id=uid"| |
− | true | + | result= |
− | + | ===XML示例=== | |
− | + | <pre> | |
− | false | + | <?xml version="1.0" encoding="UTF-8"?> |
− | + | <user> | |
− | == | + | <id>1474388131</id> |
− | + | <screen_name>.......</screen_name> | |
− | + | <name>.......</name> | |
− | + | <province>11</province> | |
− | + | <city>8</city> | |
− | + | <location>北京 海淀区</location> | |
− | + | <description>.......</description> | |
− | + | <url>http://1</url> | |
− | + | <profile_image_url>http://tp4.sinaimg.cn/1474388131/50/1287032732/1</profile_image_url> | |
− | === | + | <domain>.......</domain> |
− | + | <gender>m</gender> | |
− | + | <followers_count>40</followers_count> | |
− | + | <friends_count>97</friends_count> | |
− | + | <statuses_count>88</statuses_count> | |
− | + | <favourites_count>0</favourites_count> | |
− | + | <created_at>Tue Jul 13 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> | |
− | + | <status> | |
− | + | <created_at>Mon Dec 06 10:24:28 +0800 2010</created_at> | |
− | + | <id>4116374877</id> | |
− | + | <text>生死簿上记载,我的寿命还有17437天(约48年) http://sinaurl.cn/hbyVR6</text> | |
− | + | <source> | |
− | + | <a href="http://wanyi.sinaapp.com">玩意网</a> | |
− | + | </source> | |
− | + | <favorited>false</favorited> | |
− | + | <truncated>false</truncated> | |
− | + | <geo/> | |
− | + | <in_reply_to_status_id/> | |
− | + | <in_reply_to_user_id/> | |
− | + | <in_reply_to_screen_name/> | |
− | + | <thumbnail_pic>http://ww1.sinaimg.cn/thumbnail/57e160a3jw6dc2ondgoytg.gif</thumbnail_pic> | |
− | + | <bmiddle_pic>http://ww1.sinaimg.cn/bmiddle/57e160a3jw6dc2ondgoytg.gif</bmiddle_pic> | |
− | + | <original_pic>http://ww1.sinaimg.cn/large/57e160a3jw6dc2ondgoytg.gif</original_pic> | |
− | + | </status> | |
− | + | </user> | |
− | + | </pre> | |
− | + | ===JSON示例=== | |
− | + | <pre> | |
− | + | { | |
− | + | "name" : "........", | |
− | + | "domain" : ".........", | |
− | + | "geo_enabled" : true, | |
− | + | "followers_count" : 40, | |
− | + | "statuses_count" : 88, | |
− | </ | + | "favourites_count" : 0, |
− | </user> | + | "city" : "8", |
− | + | "description" : ".......", | |
− | JSON示例 | + | "verified" : false, |
− | + | "status" : | |
− | + | { | |
− | " | + | "created_at" : "Mon Dec 06 10:24:28 +0800 2010", |
− | " | + | "text" : "生死簿上记载,我的寿命还有17437天(约48年) http://sinaurl.cn/hbyVR6", |
− | " | + | "bmiddle_pic" : "http://ww1.sinaimg.cn/bmiddle/57e160a3jw6dc2ondgoytg.gif", |
− | " | + | "original_pic" : "http://ww1.sinaimg.cn/large/57e160a3jw6dc2ondgoytg.gif", |
− | "city":" | + | "truncated" : false, |
− | " | + | "in_reply_to_status_id" : "", |
− | " | + | "in_reply_to_screen_name" : "", |
− | " | + | "geo" : null, |
− | + | "favorited" : false, | |
− | + | "thumbnail_pic" : "http://ww1.sinaimg.cn/thumbnail/57e160a3jw6dc2ondgoytg.gif", | |
− | + | "in_reply_to_user_id" : "", | |
− | + | "id" : 4116374877, | |
− | + | "source" : "<a href=\"http://wanyi.sinaapp.com\" rel=\"nofollow\">玩意网</a>" | |
− | + | }, | |
− | + | "id" : 1474388131, | |
− | + | "gender" : "m", | |
− | + | "friends_count" : 97, | |
− | + | "screen_name" : ".......", | |
− | + | "allow_all_act_msg" : false, | |
− | + | "following" : false, | |
− | + | "url" : "http://1", | |
− | + | "profile_image_url" : "http://tp4.sinaimg.cn/1474388131/50/1287032732/1", | |
− | + | "created_at" : "Tue Jul 13 00:00:00 +0800 2010", | |
− | + | "province" : "11", | |
− | + | "location" : "北京 海淀区" | |
− | + | } | |
− | + | </pre> | |
− | + | ||
− | + | ||
− | + | ||
{{param_user}} | {{param_user}} | ||
− | {{param_status}} | + | {{param_status}}| |
+ | useAge= | ||
+ | * :id为REST风格的参数,使用该参数的URL为:<br/> http://api.t.sina.com.cn/friendships/destroy/:id.format <br/> 使用示例如下:<br/> http://api.t.sina.com.cn/friendships/destroy/123456.xml?source=appkey<br/>http://api.t.sina.com.cn/friendships/destroy/123456.json?source=appkey | ||
+ | * 关注不存在的ID返回400 | ||
+ | *<font style="color:red">此接口仅针对微博类客户端开放,非微博类客户端应用不开放此接口权限。</font>| | ||
+ | * 如果已经关注了此人,则返回http 403的状态。| | ||
+ | otherInfo= | ||
+ | ===Java示例=== | ||
+ | 请从 [[SDK | 微博SDK开发包下载]] 下载Java SDK<br> | ||
+ | 代码示例如下: | ||
+ | <pre> | ||
+ | package weibo4j.examples; | ||
− | + | import weibo4j.Weibo; | |
+ | import weibo4j.WeiboException; | ||
− | + | public class DestroyFriendship { | |
− | + | ||
− | + | /** | |
− | + | * 取消关注 | |
− | + | * @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 { | |
− | + | User user = getWeibo(true,args).destroyFriendship(args[2]);//args[2]:关注用户的id | |
− | + | System.out.println(user.toString()); | |
− | + | } catch (WeiboException 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; | |
− | + | } | |
− | + | }</pre> | |
− | + | ===PHP示例=== | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
请从 [[SDK | 微博SDK开发包下载]] 处下载PHP SDK(支持OAuth验证之版本)<br> | 请从 [[SDK | 微博SDK开发包下载]] 处下载PHP SDK(支持OAuth验证之版本)<br> | ||
代码示例如下: | 代码示例如下: | ||
第172行: | 第167行: | ||
} | } | ||
</pre> | </pre> | ||
+ | }} |
2015年6月24日 (三) 17:36的最后版本
目录 |
friendships/destroy
取消对某用户的关注。
URL
http://api.t.sina.com.cn/friendships/destroy.(json%7Cxml)
支持格式
XML/JSON
HTTP请求方式
POST/DELETE
是否需要登录
true
关于授权机制,参见授权机制声明
请求数限制
true
关于请求数限制,参见接口访问权限说明
请求参数
必选 | 类型及范围 | 说明 | |
---|---|---|---|
source | true | string | 申请应用时分配的AppKey,调用接口时候代表应用的唯一身份。(采用OAuth授权方式不需要此参数) |
:id | false | int64/string | 要取消关注的用户ID(int64)或者微博昵称(string),该参数是一个REST风格的参数。用法见注意事项 |
user_id | false | int64 | 要取消关注的用户ID,为了避免用户的ID与微博昵称相同而产生混淆的情况,推荐使用该参数。 |
screen_name | false | string | 要取消关注的用户微博昵称,为了避免用户的ID与微博昵称相同而产生混淆的情况,推荐使用该参数。 |
:id、user_id、screen_name这三个参数必填其一。 |
注意事项
- :id为REST风格的参数,使用该参数的URL为:
http://api.t.sina.com.cn/friendships/destroy/:id.format
使用示例如下:
http://api.t.sina.com.cn/friendships/destroy/123456.xml?source=appkey
http://api.t.sina.com.cn/friendships/destroy/123456.json?source=appkey - 关注不存在的ID返回400
- 此接口仅针对微博类客户端开放,非微博类客户端应用不开放此接口权限。
返回结果
XML示例
<?xml version="1.0" encoding="UTF-8"?> <user> <id>1474388131</id> <screen_name>.......</screen_name> <name>.......</name> <province>11</province> <city>8</city> <location>北京 海淀区</location> <description>.......</description> <url>http://1</url> <profile_image_url>http://tp4.sinaimg.cn/1474388131/50/1287032732/1</profile_image_url> <domain>.......</domain> <gender>m</gender> <followers_count>40</followers_count> <friends_count>97</friends_count> <statuses_count>88</statuses_count> <favourites_count>0</favourites_count> <created_at>Tue Jul 13 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> <status> <created_at>Mon Dec 06 10:24:28 +0800 2010</created_at> <id>4116374877</id> <text>生死簿上记载,我的寿命还有17437天(约48年) http://sinaurl.cn/hbyVR6</text> <source> <a href="http://wanyi.sinaapp.com">玩意网</a> </source> <favorited>false</favorited> <truncated>false</truncated> <geo/> <in_reply_to_status_id/> <in_reply_to_user_id/> <in_reply_to_screen_name/> <thumbnail_pic>http://ww1.sinaimg.cn/thumbnail/57e160a3jw6dc2ondgoytg.gif</thumbnail_pic> <bmiddle_pic>http://ww1.sinaimg.cn/bmiddle/57e160a3jw6dc2ondgoytg.gif</bmiddle_pic> <original_pic>http://ww1.sinaimg.cn/large/57e160a3jw6dc2ondgoytg.gif</original_pic> </status> </user>
JSON示例
{ "name" : "........", "domain" : ".........", "geo_enabled" : true, "followers_count" : 40, "statuses_count" : 88, "favourites_count" : 0, "city" : "8", "description" : ".......", "verified" : false, "status" : { "created_at" : "Mon Dec 06 10:24:28 +0800 2010", "text" : "生死簿上记载,我的寿命还有17437天(约48年) http://sinaurl.cn/hbyVR6", "bmiddle_pic" : "http://ww1.sinaimg.cn/bmiddle/57e160a3jw6dc2ondgoytg.gif", "original_pic" : "http://ww1.sinaimg.cn/large/57e160a3jw6dc2ondgoytg.gif", "truncated" : false, "in_reply_to_status_id" : "", "in_reply_to_screen_name" : "", "geo" : null, "favorited" : false, "thumbnail_pic" : "http://ww1.sinaimg.cn/thumbnail/57e160a3jw6dc2ondgoytg.gif", "in_reply_to_user_id" : "", "id" : 4116374877, "source" : "<a href=\"http://wanyi.sinaapp.com\" rel=\"nofollow\">玩意网</a>" }, "id" : 1474388131, "gender" : "m", "friends_count" : 97, "screen_name" : ".......", "allow_all_act_msg" : false, "following" : false, "url" : "http://1", "profile_image_url" : "http://tp4.sinaimg.cn/1474388131/50/1287032732/1", "created_at" : "Tue Jul 13 00:00:00 +0800 2010", "province" : "11", "location" : "北京 海淀区" }
字段说明 - user
- id: 用户UID
- screen_name: 微博昵称
- name: 友好显示名称,同微博昵称
- province: 省份编码(参考省份编码表)
- city: 城市编码(参考城市编码表)
- location:地址
- description: 个人描述
- url: 用户博客地址
- profile_image_url: 自定义图像
- domain: 用户个性化URL
- gender: 性别,m--男,f--女,n--未知
- followers_count: 粉丝数
- friends_count: 关注数
- statuses_count: 微博数
- favourites_count: 收藏数
- created_at: 创建时间
- following: 是否已关注(此特性暂不支持)
- verified: 加V标示,是否微博认证用户
字段说明 - status
- created_at: 创建时间
- id: 微博ID
- text: 微博信息内容
- source: 微博来源
- favorited: 是否已收藏
- truncated: 是否被截断
- in_reply_to_status_id: 回复ID
- in_reply_to_user_id: 回复人UID
- in_reply_to_screen_name: 回复人昵称
- thumbnail_pic: 缩略图
- bmiddle_pic: 中型图片
- original_pic:原始图片
- user: 作者信息
- retweeted_status: 转发的博文,内容为status,如果不是转发,则没有此字段
其他
Java示例
请从 微博SDK开发包下载 下载Java SDK
代码示例如下:
package weibo4j.examples; import weibo4j.Weibo; import weibo4j.WeiboException; public class DestroyFriendship { /** * 取消关注 * @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 { User user = getWeibo(true,args).destroyFriendship(args[2]);//args[2]:关注用户的id System.out.println(user.toString()); } catch (WeiboException 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验证之版本)
代码示例如下:
//friendships/destroy //取消关注 $c = new WeiboClient( WB_AKEY , WB_SKEY , $_SESSION['last_key']['oauth_token'] , $_SESSION['last_key']['oauth_token_secret'] ); //关注用户的id $u_id = "u_id"; $msg = $c->unfollow($u_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; } if (isset($msg['screen_name'])){ echo('Unfollow Friend:'.$msg['screen_name']); }
文档更新时间: 2015-06-24