Xweibo微博API接口说明.docx
《Xweibo微博API接口说明.docx》由会员分享,可在线阅读,更多相关《Xweibo微博API接口说明.docx(33页珍藏版)》请在冰豆网上搜索。
Xweibo微博API接口说明
Xweibo微博API接口说明
Xweibo
2011年6月
目 录
目录
1接口概述1
2API调用说明1
2.1参数说明:
1
2.2Api访问方式说明:
1
3API返回值说明2
3.1返回格式:
json2
3.2返回结构:
{"rst":
返回结果,"errno":
结果代码,"err":
"错误提示信息"}2
4错误代码2
4.1参数检查错误代码:
2
4.2平台级别错误代码:
3
5接口介绍3
5.1微博访问接口3
5.1.1action.update:
发布一条微博消息3
5.1.2action.destroy:
删除一条微博信息4
5.1.3action.repost:
转发一条微博信息5
5.1.4ment:
对一条微博信息进行评论6
5.1.5ment.destroy:
删除微博评论6
5.1.6action.reply:
回复微博评论消息7
5.2关注接口9
5.2.1action.createFriendship:
关注某用户9
5.2.2action.deleteFriendship:
取消关注或移除粉丝10
5.2.3action.friendship:
查看某人是否为指定用户的粉丝10
5.3收藏接口11
5.3.1action.createFavorite:
添加收藏11
5.3.2action.deleteFavorite:
删除收藏11
5.4账号接口12
5.4.1action.updateProfileImage:
更改头像12
5.4.2action.saveProfile:
更改个人资料12
5.5获取下行数据集(Timeline)接口13
5.5.1action.unread:
获取当前用户未读消息数13
5.5.2action.getComments:
获取指定微博的评论列表13
5.5.3action.getCounts:
批量获取评论数和转发数15
5.5.4action.clearTip:
未读消息数清零接口15
5.6私信接口16
5.6.1action.sendDirectMessage:
发送私信16
5.6.2action.deleteDirectMessage:
删除私信16
5.7用户接口17
5.7.1action.createBlocks:
加入黑名单17
5.7.2action.deleteBlocks:
删除黑名单17
5.7.3action.createTags:
添加标签18
5.7.4action.deleteTags:
删除标签18
5.8其它接口19
5.8.1action.setting:
tip个人设置19
5.8.2action.sinaurl:
解析短链接19
5.8.4action.saveNotice:
更新提醒设置和tip显示方式21
Xweibo微博API接口说明
1接口概述
Xweibo不仅提供了快速、低成本架设微博的解决方案,还提供了让第三方调用的API接口。
第三方通过调用这些API接口可以轻松地为Xweibo推送内容,同时也能够从Xweibo获取所需的内容,在自有网站上进行展示。
Xweibo微博API接口是一座连接第三方网站与Xweibo的桥梁。
通过它,站长可以实现自有站点与Xweibo无缝连接,进行无障碍的内容共享。
2API调用说明
2.1参数说明:
在请求api的同时,post多以下三个参数:
api_sign:
签名值:
md5(API_WB_AKEY.'#'.$api_uid.'#'.$api_time.'#'.API_WB_SKEY.'#'.$m.'#'.API_KEY);
API_WB_AKEY:
默认使用申请微博应用的appkey
API_WB_SKEY:
默认使用申请微博应用的appsecret
$m:
是访问api的接口名。
比如要访问发微博api,$m=‘update’。
API_KEY:
约定加密的key
api_uid:
第三方绑定的用户uid
api_time:
当前请求的时间,时间戳。
2.2Api访问方式说明:
某些api允许使用匿名身份或者系统默认帐号进行访问
如果需要使用匿名身份访问部分api:
请设置变量:
$allow_anonymous的值,默认是空数组。
比如
$allow_anonymous=array(‘getTokenAuthorizeURL’);
那么接口:
getTokenAuthorizeURL就可以使用匿名身份访问
如果需要使用默认帐号访问部分api:
请设置变量:
$allow_others的值,默认是空数组。
比如
$allow_others=array(‘update’,’comment’);
那么接口:
update和comment就可以使用系统帐号访问
使用这个两种方式访问api,api_uid可以为空或一个不存在的uid值。
3API返回值说明
3.1返回格式:
json
3.2返回结构:
{"rst":
返回结果,"errno":
结果代码,"err":
"错误提示信息"}
1)返回结果:
json格式的字符串或单独的字符
2)结果代码:
正确的返回是:
0,错误的返回是:
一个错误代码
3)错误提示信息:
方便分析问题。
(自定义的或接口本身的错误内容)
4错误代码
错误以7位数字表示。
比如:
1010000前两位表示:
主类别,第二,三位表示:
子类别,后三位用来表示错误代码。
错误代码分为公共的错误代码和接口特定的错误代码。
参数检查错误代码以及平台级别错误属于公共的错误代码,如下所示:
4.1参数检查错误代码:
错误代码
说明
errno:
1010000
err:
Parametercannotbeempty
参数不能为空。
errno:
1010002
err:
Parametermustbeanumber
参数必须为数字。
errno:
1010003
err:
Parametersfortheemailtoformat
参数格式必须为email格式。
errno:
1010004
err:
Parametersforjsonrequestdirectlytoformat
参数格式必须为json格式。
errno:
1010005
err:
Parameterlengthexceedslimit
参数长度超出限制。
errno:
1010006
err:
Parametercannotusesinaemail
参数email不能用sina域下的邮箱。
errno:
1010007
err:
Parameterscontainsensitivecharacters
参数含有敏感字符。
4.2平台级别错误代码:
错误代码
说明
errno:
1040000
err:
40113:
OauthError:
token_rejected!
token不合法。
error:
1040001
err:
40313:
Error:
invalidweibouser!
当前用户没有开通微博。
error:
1040002
err:
AccessTimeoutorAccessdenied
api访问超时或拒绝访问。
error:
1040003
err:
sourceparamter(appkey)ismissing
oauthtoken为空。
error:
1040004
err:
40028:
请不要发表违法和不良信息!
当前用户在官方微博上给屏蔽。
error:
1040005
err:
40028:
黑名单用户
当前用户是黑名单用户。
5接口介绍
5.1微博访问接口
5.1.1action.update:
发布一条微博消息
4)URL:
http:
//server/?
m=api/weibo/action.update
5)请求参数:
名称
描述
text
微博内容,不能为空,内容不能超过140个汉字
pic
图片pid,有传该参数就是分享图片,没有就是发微博
httpmethod
POST
6)
"rst":
{"data":
{"id":
"3070003351",
"cr":
"WedOct1318:
55:
42+08002010",
"f":
0,
"s":
"\/\/\/\"rel=\"nofollow\">discuz\u63d2\u4ef6<\/a>",
"tx":
"[\u54c8\u54c8]",
"tp":
null,
"mp":
null,
"op":
null,
"u":
{"id":
"1819991891",
"sn":
"test_weibo",
"p":
"http:
\/\/\/1819991891\/50\/0",
"v":
0,
"sina_v":
0}
}
},
"errno":
0,"err":
""}
返回格式:
7)接口错误代码:
错误代码
说明
errno:
1020000
err:
40012:
Error:
contentisnull!
发微博内容不能为空。
errno:
1020001
err:
40013:
Error:
Texttoolong,pleaseinputtextlessthan140characters!
发微博内容超过140个字。
errno:
1020002
err:
40025:
Error:
repeatedweibotext!
发微博内容重复。
5.1.2action.destroy:
删除一条微博信息
8)URL:
http:
//server/?
m=api/weibo/action.destroy
9)参数列表:
名称
描述
id
微博id
httpmethod
POST
10)
{"rst":
true,"errno":
0,"err":
""}
返回格式:
11)接口错误代码:
错误代码
说明
errno:
1020300
err:
40016:
Error:
weiboidisnull!
删除微博id为空。
errno:
1020301
err:
40031:
Error:
targetweibodoesnotexist!
删除微博id不存在。
errno:
1020302
err:
40036:
Error:
notyourownweibo!
删除的微博不是本人发的。
5.1.3action.repost:
转发一条微博信息
12)URL:
http:
//server/?
m=api/weibo/action.repost
13)参数列表
名称
描述
id
微博id
text
微博内容,不能为空,内容不能超过140个汉字
rtids
作为某人的评论,多个用逗号隔开
httpmethod
POST
14)
{"rst":
{"data":
{"id":
"3070211503",
"cr":
"WedOct1319:
10:
33+08002010",
"f":
0,
"s":
"\/\/\/\"rel=\"nofollow\">discuz\u63d2\u4ef6<\/a>",
"tx":
"\u8f6c\u53d1\u5fae\u535a",
"tp":
null,
"mp":
null,
"op":
null,
"u":
{"id":
"1819991891",
"sn":
"test_weibo",
"p":
"http:
\/\/\/1819991891\/50\/0",
"v":
0,
"sina_v":
0},
"rt":
{"id":
"3070003351",
"cr":
"WedOct1318:
55:
42+08002010",
"f":
0,
"s":
"\/\/\/\"rel=\"nofollow\">discuz\u63d2\u4ef6<\/a>",
"tx":
"[\u54c8\u54c8]",
返回格式:
15)
"tp":
null,
"mp":
null,
"op":
null,
"u":
{"id":
"1819991891",
"sn":
"test_weibo",
"p":
"http:
\/\/\/1819991891\/50\/0",
"v":
0,
"sina_v":
0}}
}
},
"errno":
0,"err":
""}
接口错误代码
错误代码
说明
errno:
1020200
err:
40016:
Error:
weiboidisnull!
转发微博id为空。
errno:
1020201
err:
40013:
Error:
Texttoolong,pleaseinputtextlessthan140characters!
转发微博内容超过140个字。
5.1.4ment:
对一条微博信息进行评论
16)URL:
http:
//server/?
m=api/weibo/ment
17)参数列表:
名称
描述
id
微博id
text
微博内容,不能为空,内容不能超过140个汉字
forward
是否作为一条新微博发布,1是,0不作为
type
评论显现头像类型,默认是1,30大小的头像,2,50大小的头像
httpmethod
POST
18)
{"rst":
{"comment":
{"id":
"3818812429",
"create_at":
"1\u5206\u949f\u524d",
"text":
"test",
"nick":
"test_weibo",
"uid":
"1819991891",
"profileImg":
"http:
\/\/\/1819991891\/30\/0","sina_v":
0}
},
"errno":
0,"err":
""}
返回格式:
19)接口错误代码:
错误代码
说明
errno:
1020400
err:
40016:
Error:
weiboidisnull!
评论微博id为空。
errno:
1020401
err:
40012:
Error:
contentisnull!
评论微博内容为空。
errno:
1020402
err:
40031:
Error:
targetweibodoesnotexist!
评论微博id不存在。
errno:
1020403
err:
40013:
Error:
Texttoolong,pleaseinputtextlessthan140characters!
评论微博内容超过140个字。
5.1.5ment.destroy:
删除微博评论
20)URL:
http:
//server/?
m=api/weibo/ment_destory
21)参数列表:
名称
描述
id
评论微博id(多个id用逗号隔开)
httpmethod
POST
22)
{"rst":
{"total":
null},"errno":
0,"err":
""}
返回格式:
23)接口错误代码
错误代码
说明
errno:
1020600
err:
40020:
Error:
Commentidisnull!
删除评论id为空。
errno:
1020601
err:
40015:
Error:
notyourowncomment!
删除评论id不存在或不是本人发的。
errno:
1020602
err:
删除评论失败。
5.1.6action.reply:
回复微博评论消息
24)URL:
http:
//server/?
m=api/weibo/action.replay
25)参数列表:
名称
描述
id
微博id
cid
要评论的评论id
text
微博内容,不能为空,内容不能超过140个汉字
forward
是否作为一条新微博发布,1是,0不作为
type
评论显现头像类型,默认是1,30大小的头像,2,50大小的头像
httpmethod
POST
26)
{"rst":
{"comment":
{"id":
"3818812429",
"create_at":
"1\u5206\u949f\u524d",
"text":
"test",
"nick":
"test_weibo",
"uid":
"1819991891",
"profileImg":
"http:
\/\/\/1819991891\/30\/0",
"sina_v":
0},
"wb":
{"id":
"3070211503",
"cr":
"WedOct1319:
10:
33+08002010",
"f":
0,
"s":
"\/\/\/\"rel=\"nofollow\">discuz\u63d2\u4ef6<\/a>",
"tx":
"\u8f6c\u53d1\u5fae\u535a",
"tp":
null,
"mp":
null,
"op":
null,
"u":
{"id":
"1819991891",
"sn":
"test_weibo",
"p":
"http:
\/\/\/1819991891\/50\/0",
"v":
0,
"sina_v":
0},
"rt":
{"id":
"3070003351",
"cr":
"WedOct1318:
55:
42+08002010",
"f":
0,
"s":
"\/\/\/\"rel=\"nofollow\">discuz\u63d2\u4ef6<\/a>",
"tx":
"[\u54c8\u54c8]",
"tp":
null,
"mp":
null,
"op":
null,
"u":
{"id":
"1819991891",
"sn":
"test_weibo",
"p":
"http:
\/\/\/1819991891\/50\/0",
返回格式:
"v":
0,"sina_v":
0}
}
},
"errno":
0,"err":
""}
27)接口错误代码:
错误代码
说明
errno:
1020500
err:
40016:
Error:
weiboidisnull!
回复评论微博id为空。
errno:
1020501
err:
40020:
Error:
Commentidisnull!
回复评论评论id为空。
errno:
1020502
err:
40012:
Error:
contentisnull!
回复评论评论内容为空。
errno:
1020503
err:
40013:
Error:
Texttoolong,pleaseinputtextlessthan140characters!
回复评论评论内容超过140个字。
errno:
1020504
err:
40031:
Error:
targetweibodoesnotexist!
回复评论微博id不存在。
5.2关注接口
5.2.1action.createFriendship:
关注某用户
28)URL:
http:
//server/?
m=api/weibo/action.createFriendship
29)参数列表:
名称
描述
uid
要关注的用户UID或微博昵称(用户id,支持批量关注,多个用逗号隔开)
type
类型,默认是0,0表示uid是用户id,1表示uid是微博昵称
httpmethod
POST
30)
{"rst":
true,"errno":
0,"err":
""}
返回格式:
31)接口错误代码:
错误代码
说明
errno:
1020800
err:
40028:
添加关注操作失败
关注的用户id为空或本人。
errno:
1020801
err:
40028:
fuid错误
关注的用户id不存在。
errno:
1020804
err:
关注失败。
5.2.2action.deleteFriendship:
取消关注或移除粉丝
32)URL:
http:
//server/?
m=api/weibo/action.deleteFriendship
33)参数列表:
名称
描述
id
用户UID
name
要关注的微博昵称
is_follower
默认为0。
1表示为移除粉丝,0表示为取消关注
httpmethod
POST
34)
{"rst":
true,"errno":
0,"err":
""}
返回格式:
35)接口错误代码:
错误代码
说明
errno:
1020802
err:
40028:
fuid错误
取消关注的用户id为空或不存在。
errno:
1020803
err:
40028:
fuid错误
取消关注的用户name为空或不存在。
5.2.3action.friendship:
查看某人是否为指定用户的粉丝
36)URL:
http:
//server/?
m=api/weibo/action.friendship
37)参数列表:
名称
描述
t_id
要判断的目的用户UID
t_name
要判断的目的微博昵称
s_id
源用户UID(不指定,就使用当前登录用户)
s_name
源微博昵称(不指定,就使用当前登录用户)
httpmethod
POST
38)
{"rst":
true,"errno":
0,"err":
""}
返回格式:
39)接口错误代码:
错误代码
说明
errno:
1021200
err:
40026:
Error:
pleaseinputrighttargetuserid(orscreen_name)!
要判断的目的用户id或name不存在。
40)
5.3收藏接口
5.3.1action.createFavorite:
添加收藏
41)URL:
http:
//server/?
m=api/weibo/action.createFavorite