首页
社区
课程
招聘
[分享]看雪论坛移动客户端接口(登陆接口己失效)
发表于: 2013-2-26 19:57 41925

[分享]看雪论坛移动客户端接口(登陆接口己失效)

2013-2-26 19:57
41925
说明:
1)目前接口还不完善,其他功能接口根据需求慢慢完善。
2)接口输出的数据格式是JSON
3)若不慎用浏览器访问了下面的请求地址,要回到正常的论坛版面,请将参数styleid=1,切记! 即:http://bbs.pediy.com?styleid=1
4)客户端登录之后,每次与服务端交互都要携带登录接口返回的cookie

一、通信接口

功能说明
获取论坛的securitytoken。

注意:
1)登录接口会返回securitytoken,每次重新启动app还需要通过getsecuritytoken.php接口重新获得securitytoken。
2)securitytoken在登录后发帖和回帖时候都需要post给服务器。

调用说明
请求方式:get方式
请求地址:http://bbs.pediy.com/getsecuritytoken.php?styleid=12
参数:无

返回结果
返回参数说明:
Name               Type       Description
securitytoken      string    登陆的securitytoken

返回JSON样例
http://bbs.pediy.com/getsecuritytoken.php?styleid=12

游客返回:{"securitytoken":"guest"}
登陆用户返回:{"securitytoken":"1359867494-08bb18b39bb0a502c57c219ea8fbd5ed4ded1222"}


二、登陆、退出论坛

[QUOTEd=1)登陆接口]
功能说明
登陆bbs.pediy.com论坛
post方式。

参数说明:
Name                                         Type                Description
vb_login_username                                   string             用户名
do:login            
cookieuser:1
securitytoken:guest
vb_login_md5password:                                                string                                        密码的MD5值       
vb_login_md5password_utf:

vb_login_md5password值生成方式:
(1). 取出密码中的前后空格 trim()
(2). 对上步结果做一下java方法处理
private String strToEnt(String input) {
        String output = "";
       
        for (int i = 0; i < input.length(); i++) {
                int ucode = input.codePointAt(i);
                String tmp = "";
               
                if (ucode > 255) {
                        while (ucode >= 1) {
                                tmp = "0123456789".charAt(ucode%10) + tmp;
                                ucode /= 10;
                        }
                       
                        if (tmp == "") {
                                tmp = "0";
                        }
                       
                        tmp = "#" + tmp;
                        tmp = "&" + tmp;
                        tmp = tmp + ";";
                        output += tmp;
                }else {
                        output += input.charAt(i);
                }
        }
        return output;
}
(3). 对上步所得值进行md5

vb_login_md5password_utf值生方式:
直接去除密码前后空格字符后计算md5

返回结果
登陆成功:
返回参数说明:
Name          Type                Description
result            int                    返回0,表示登陆成功
username    string               用户名
userid           int                    用户ID
isavatar        int                     是否有头像,0没有头像,1有头像
email           string                邮箱地址
securitytoken        string

返回JSON样例
{"result":0,"username":"小宝"."userid":2,"isavatar":1,"email":"test@pediy.com","securitytoken":"1360055797-c8760f9bb81db38c470ff1eea3cbe33dc4d06692"}

登陆失败:
返回参数说明:
Name          Type                Description
result          int                 返回1,表示登陆失败
strikes         int                 尝试登陆的次数

返回JSON样例
{"result":1,"strikes":2}

论坛提示信息
当strikes<5提示:用户名和密码不对,您已经使用了 5 次登录尝试限制中的 {2} 次。在使用完 5 次尝试机会后,您在 15 分钟内将无法登录。
当strikes>=5提示:错误的用户名或密码。 您已经超出了登录失败限制次数!请等待 15 分钟后重试。

2)退出接口

功能说明
退出论坛
get方式。
需提交cookie
参数:http://bbs.pediy.com/login.php??do=logout&logouthash= (此处为通过getsecuritytoken接口获得的securitytoken)&styleid=12

返回结果
返回参数说明:
Name          Type                Description
result           int                    成功退出返回0

返回JSON样例
echo "{\"result\":0}";



[/QUOTEd]
三、用户信息

[QUOTEd=1)取用户的个人资料]
功能说明
获取用户的信息。

调用说明
请求地址:http://bbs.pediy.com/member.php?u=userid&styleid=12
参数:
userid:UNIT 用户ID

返回结果

返回参数说明:
Name Type Description
username string 用户ID
userid int 用户名
usertitle string 用户头衔
posts int 发帖数
languageid int 用户浏览语音
money int 用户金钱数
goodnees int 精华数
avatar int 是否有头像,0无头像,1有头象
avatardateline int 头像上传日期时间戳,如无头像返回0

返回JSON样例
http://bbs.pediy.com/member.php?u=372322&styleid=12

[{'username':'loongzyd','userid':'372322','usertitle':'『新人交流投稿』版主
『CrackMe◇ReverseMe』版主','posts':'865','languageid':'1','money':'1385','goodnees':'10', 'avatar':'1','avatardateline':'1311388471'}]


[/QUOTEd]
四、版面、帖子信息

[QUOTEd=1)取论坛版面列表]
功能说明
获得 论坛首页版面列表

调用说明
请求地址:http://bbs.pediy.com/index.php?styleid=12
登录之后需要提交cookie

返回结果
返回参数说明:
Name                Type    Description
forumTitle         string   论坛区名  
forumSubTitle  结构体  论坛版面,有三个参数name,id,imgId

forumSubTitle相关参数说明:
Name                Type    Description
name                string  论坛版面的名称
id                      int       论坛版面的ID
imgId               int        论坛版面图片ID,暂时没有,默认为0

返回JSON样例:

{"forumbits":[{forumTitle:"初学者园地",forumSubTitle:[{name:"『新人交流投稿』",id:131,imgId:0},{name:"『求助问答区』",id:20,imgId:0},{name:"『伴你成长』",id:139,imgId:0}]},{forumTitle:"Windows安全",forumSubTitle:[{name:"『软件调试论坛』",id:4,imgId:0},{name:"『编程技术』",id:41,imgId:0},{name:"『加壳与脱壳』",id:88,imgId:0},{name:"『病毒木马分析』",id:30,imgId:0},{name:"『密码学算法』",id:132,imgId:0},{name:"『CrackMe◇ReverseMe』",id:37,imgId:0},{name:"『外文翻译区』",id:32,imgId:0},{name:"『资源下载』",id:10,imgId:0}]},{forumTitle:"移动平台安全",forumSubTitle:[{name:"『Android 开发』",id:159,imgId:0},{name:"『Android 安全』",id:161,imgId:0},{name:"『iOS安全』",id:166,imgId:0},{name:"『Windows Phone安全』",id:167,imgId:0}]},{forumTitle:"信息安全",forumSubTitle:[{name:"『WEB安全』",id:151,imgId:0},{name:"『漏洞分析预警』",id:150,imgId:0},{name:"『云计算安全』",id:162,imgId:0},{name:"『硬件与通信安全』",id:128,imgId:0}]},{forumTitle:"职场风云",forumSubTitle:[{name:"『招聘专区』",id:47,imgId:0},{name:"『人才资源库』",id:55,imgId:0},{name:"『职业生涯』",id:137,imgId:0}]},{forumTitle:"论坛生活",forumSubTitle:[{name:"『生活放心情』",id:45,imgId:0},{name:"『软件使用』",id:111,imgId:0},{name:"『论坛活动』",id:109,imgId:0}]},{forumTitle:"软件安全图书",forumSubTitle:[{name:"『图书项目版』",id:65,imgId:0}]},{forumTitle:"软件安全图书",forumSubTitle:[]},{forumTitle:"站务管理",forumSubTitle:[{name:"『论坛版务』",id:2,imgId:0},{name:"『回收站』",id:57,imgId:0}]}]}

2)取版面的主题帖列表

功能说明
获得论坛版面的主题帖,主题帖称为thread

调用说明
请求地址:http://bbs.pediy.com/forumdisplay.php?f=forumid?styleid=12
登录之后需要提交cookie

参数说明:
Name                Type    Description
forumid             int       论坛版面ID

返回结果
返回参数说明:
Name                Type    Description
time                   int       取主题帖的当前时间戳
pagenav            int       这个版面主题帖有多少页(导航条里的最大数)
threadList         结构体  帖子具体信息

threadList 相关参数说明:
Name                Type      Description
threadtitle         string    帖子的标题
threadid            int         帖子的ID
postusername   string   帖子的作者
postuserid         int        帖子作者的ID
avatar                int        作者是否有头像,0没有,1有
avatardateline   int       作者上传头像的时间戳
lastpostdate      int       帖子被回复的时间
views                  int       帖子的查看数
replycount         int       帖子被回复数
globalsticky       int       是否全局置顶,全局置顶该字段为-1,否则为0
sticky                 int        是否置顶帖,置顶帖该字段为1,否则为0
goodnees          int       是否为精华帖
   0:表示不是精华帖
   1:转帖
   2:关注
   10:优秀
   40:精华
   80:酷帖
若是工具下载版,该字段含义:
  1:收集
  10: 利器
  30 :独家

返回JSON样例:
http://bbs.pediy.com/forumdisplay.php?f=4?styleid=12

{"time":1359880438,"pagenav":1401,"threadList":[{"threadtitle":"科锐培训,从事逆向工程师培训","threadid":51839,"postusername":"backer","postuserid":8866,"avatar":1,"avatardateline":"1204982702","lastpostdate":"2013-02-01","views":274467,"replycount":718,"globalsticky":-1,"sticky":1,"goodnees":0},{"threadtitle":""麦洛克菲"内核驱动开发培训(三期预告)","threadid":142155,"postusername":"MallocFree","postuserid":463708,"avatar":0,"avatardateline":"0","lastpostdate":"2013-02-02","views":170427,"replycount":153,"globalsticky":-1,"sticky":0,"goodnees":0},{"threadtitle":"【2013礼物】《看雪论坛精华12》发布下载!","threadid":160513,"postusername":"kanxue","postuserid":93,"avatar":1,"avatardateline":"1328408022","lastpostdate":"2013-02-01","views":19799,"replycount":255,"globalsticky":0,"sticky":1,"goodnees":0}]}

3)取版面的主题帖列表

功能说明
获得帖子列表详细信息,单独的帖子称为post

调用说明
请求地址:http://bbs.pediy.com/showthread.php?t=threadid?styleid=12
登录之后需要提交cookie

参数说明:
Name                Type    Description
threadid            int        主题帖的ID

返回结果
返回参数说明:
Name                Type    Description
time                   int       取主题帖的当前时间戳
pagenav            int       这个版面主题帖有多少页(导航条里的最大数)
postbits             结构体 单个post里详细信息

postbits 结构说明:
Name                Type    Description
postid                int       帖子ID
thumbnail         int       是否含有缩略图,暂时没启有,默认为0
username          string  帖子作者的用户名
userid                int       帖子作者的用户ID
avatar                int       帖子作者是否有头像,0没有头像,1有头像
avatardateline  int       帖子作者头像的时间戳,如果没头像则为0
posttime           string  帖子的时间,格式如:12:13:14
postdate           string   帖子的日期,格式如:2013-01-30
title                   string   帖子的标题内容
message           string   帖子的主体内容
thumbnailattachments  结构体  附件

thumbnailattachments 结构说明:
Name                Type    Description
attachmentid    int       附件ID
filename            string  附件文件名
filesize               int       附件大小

返回JSON样例:
http://bbs.pediy.com/showthread.php?t=161964?styleid=12

{"time":1359885305,"pagenav":0,"postbits":[{"postid":"1139493","thumbnail":0,"username":"kanxue","userid":93,"avatar":"1","avatardateline":"1328408022","posttime":"12:13:14","postdate":"2013-01-30","title":"【测试】附件图片测试2","message":'再次测试~~<br /><img  src="http://bbs.pediy.com/attachment.php?attachmentid=76125&thumb=1&d=1359535385"><br />大家好',"thumbnailattachments":[{"attachmentid": "76126","filename": "meigus15.jpg","filesize": "7626"},{"attachmentid": "76128","filename": "W020121221530237405253.jpg","filesize": "5731"}]  ,"otherattachments":[,{"attachmentid": "76239","filename": "test.rar","filesize": "53298"}] }]}

[/QUOTEd]
五、发帖、回帖接口

[QUOTEd=1)发帖接口]
功能说明
通过post方式,在论坛发表新的主题帖
http://bbs.peidy.com/newthread.php?styleid=12
需要提交cookie

post参数:
subject: 帖子主题
message: 帖子内容
securitytoken:每次应用启动通过getsecuritytoken
f: 版面id
do:postthread

返回结果
返回参数说明:
(1)发帖成功返回值
Name                Type    Description
result                 int       发帖的返回值,成功返回0
threadid            int        若发帖成功返回被发主题帖的ID

返回JSON样例:
{"result":0,"threadid":161965}

(2)本论坛允许的发表两个帖子的时间间隔必须大于 {1} 秒。请等待 {2} 秒后重试。
Name                        Type            Description
result                          int         1
floodchecktime         int         提示发帖时间间隔是多少秒
flood_wait                  int        还需要等多少秒发

返回JSON样例:
{"result":1,"floodchecktime":30,"flood_wait":12}
表示:本论坛允许的发表两个帖子的时间间隔必须大于30 秒。请等待12秒后重试。

(3)此帖是您在最后 5 分钟发表的帖子的副本,您将返回该主题。
Name                        Type            Description
result                          int         2

返回JSON样例:
{"result":2}

(4)发帖少于6个字符返回值
Name                        Type            Description
result                          int         3
返回JSON样例:
{"result":3}
(5)悬赏金额不足
在『求助问答区』版块,发帖需要消费kx,悬赏金额限制: 10 - 100 Kx,这块论坛没有设接口返回,建议app自行判断用户输入的金额是不是在这个范围。

2)回帖接口

功能说明
通过post方式,完成回帖
http://bbs.pediy.com/newreply.php?styleid=12
需要提交cookie

post参数:
message:回帖内容
t: 帖子id
fromquickreply:1
do:postreply
securitytoken: 每次应用启动通过getsecuritytoken

返回结果
返回参数说明:
(1)发帖成功返回值
Name                Type    Description
result                 int       发帖的返回值
threadid            int        若发帖成功返回被跟主题帖的ID

result 参数说明:
0:成功
1:本论坛允许的发表两个帖子的时间间隔必须大于10秒。

返回JSON样例:
{"result":0,"threadid":161965}

(2)本论坛允许的发表两个帖子的时间间隔必须大于 {1} 秒。请等待 {2} 秒后重试。
Name                        Type            Description
result                          int         1
floodchecktime         int         提示发帖时间间隔是多少秒
flood_wait                  int        还需要等多少秒发

返回JSON样例:
{"result":1,"floodchecktime":30,"flood_wait":12}
表示:本论坛允许的发表两个帖子的时间间隔必须大于30 秒。请等待12秒后重试。

(3)此帖是您在最后 5 分钟发表的帖子的副本,您将返回该主题。
Name                        Type            Description
result                          int         2

返回JSON样例:
{"result":2}

(4)发帖少于6个字符返回值
Name                        Type            Description
result                          int         3
返回JSON样例:
{"result":3}


3)判断论坛版面有没有新的回帖和主题帖

功能说明
判断论坛版面的有没有新的主题帖和回帖

调用说明
请求地址:http://bbs.pediy.com/forumdisplay.php?f=forumid&getnewpost=time&styleid=12
登录用户需要提交cookie

参数说明:
Name                Type    Description
forumid             int       论坛版面ID
time                   int       时间戳,若主题帖或回帖的时间大于这个时间戳则返回1,否则返回0

返回参数说明:
Name                        Type            Description
result                          int         无新帖返回0,有新帖返回1

返回JSON样例:
{"result":1}

4)判断某个主题帖有没有新的回帖

功能说明
判断某个主题帖有没有新的回帖

调用说明
http://bbs.pediy.com/showthread.php?t=threadid&styleid=12&getnewpost=time
登录用户需要提交cookie

参数说明:
Name                Type    Description
threadid            int        帖子的ID
time                   int       时间戳,若回帖的时间大于这个时间戳则返回1,否则返回0

返回参数说明:
Name                        Type            Description
result                          int         无新帖返回0,有新帖返回1

返回JSON样例:
{"result":1}

5)根据id获取头像图片

http://bbs.pediy.com/image.php?u= (userid)
登录或者非登录状态均不需提交cookie

6)获取附件或者文章中图片

http://bbs.pediy.com/attachment.php?attachmentid= (附件id) &thumb=1&styleid=12
登录状态需提交cookie

7)获取缩略文章的完整内容

http://bbs.pediy.com/showpost.php?styleid=12&p=(帖子id)
登录状态需提交cookie

[/QUOTEd]
六、LBS

功能说明
获取周围附近好友功能。

待续……

[课程]Android-CTF解题方法汇总!

收藏
免费 0
支持
分享
最新回复 (25)
雪    币: 112
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
碉堡了,看雪也走开放路线?
2013-2-26 20:39
0
雪    币: 305
活跃值: (61)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
娘子,快跟牛魔王出来围观BOOS
2013-2-26 22:26
0
雪    币: 544
活跃值: (55)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
4
感觉论坛,用UC浏览器什么的已经优化得挺好了。。
2013-2-26 22:51
0
雪    币: 145
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
开源喽~~~看雪加油撒
2013-2-28 22:37
0
雪    币: 191
活跃值: (335)
能力值: ( LV9,RANK:450 )
在线值:
发帖
回帖
粉丝
6
期待IOS版客户端上架APP商店
2013-3-1 02:20
0
雪    币: 6278
活跃值: (137)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
7
进入移动时代了
2013-3-1 06:35
0
雪    币: 32
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
8
今晚風和日麗,沒想到小孃子你也睡不着啊.老大,開始走移動開發的路線了。支持下
2013-3-4 12:48
0
雪    币: 224
活跃值: (16)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
9
这个要顶,太感谢了。
2013-3-6 12:41
0
雪    币: 204
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
10
学习下,这下通过android和ios客户端访问很方便了!!
2013-4-1 11:03
0
雪    币: 37
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
11
这个挺好的。
2013-4-4 22:34
0
雪    币: 20570
活跃值: (3790)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
12
期待下文。。。谢谢!
2013-4-22 13:44
0
雪    币: 55
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
13
等待客户端。。
2013-4-22 14:04
0
雪    币: 20
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
KGC
14
我想问一下为什么 api 接口不以标准的 JSON 格式返回数据,比如bbs.pediy.com/index.php?styleid=12 这个接口 返回的字符串都不符合json标准格式的?
2013-5-11 17:16
0
雪    币: 122
活跃值: (75)
能力值: ( LV7,RANK:100 )
在线值:
发帖
回帖
粉丝
15
meigus16.rar22222222222222
http://www.baidu.com
上传的附件:
2013-6-2 16:34
0
雪    币: 357
活跃值: (44)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
16
要是做成chm格式的就更好了,支持开放。。
2013-6-4 16:30
0
雪    币: 260
活跃值: (102)
能力值: ( LV9,RANK:170 )
在线值:
发帖
回帖
粉丝
17
获得 论坛首页版面列表 这个json不规范啊。囧rz。
2013-6-24 17:52
0
雪    币: 231
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
18
真心期待 ios客户端 进商店
2013-8-13 11:20
0
雪    币: 43
活跃值: (12)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
19
发贴那个api,我没有调试通过。
Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo=0x7fad287a6da0 {NSUnderlyingError=0x7fad287a5770 "A server with the specified hostname could not be found.", NSErrorFailingURLStringKey=http://bbs.peidy.com/newthread.php?styleid=12, NSErrorFailingURLKey=http://bbs.peidy.com/newthread.php?styleid=12, _kCFStreamErrorDomainKey=12, _kCFStreamErrorCodeKey=8, NSLocalizedDescription=A server with the specified hostname could not be found.}
2014-10-3 10:48
0
雪    币: 105
活跃值: (14)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
20
ios的好多json解析器对invalid的json都是直接抛异常不处理的,麻烦老大处理一下吧,不懂php,但猜测应该是一个系统函数就能搞定的
2014-12-1 13:56
0
雪    币: 188
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
21
看雪移动端有人维护么?为什么android客户端总是登录不了呢?
2014-12-17 10:20
0
雪    币: 215
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
22
我在搜狗浏览器的"高速"模式试用了一些顶楼公开的接口,然后, 高速模式的浏览就变成这种移动模式了.
需要删除cookies 才能恢复?
2015-1-15 18:56
0
雪    币: 246
活跃值: (12)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
23
老大,取版面的接口,只能取到 forum 一级,取不到子论坛
比如         看雪安全论坛 > 移动平台 > 『Android 安全』 > 『Android 开发』
只能取到『Android 安全』一级,『Android 开发』是没有的
这个接口有更新的计划吗?
2016-8-14 19:52
0
雪    币: 317
活跃值: (72)
能力值: ( LV5,RANK:60 )
在线值:
发帖
回帖
粉丝
24
请更新一下登录接口文档,无法登录了!
2016-8-28 12:04
0
雪    币: 44229
活跃值: (19960)
能力值: (RANK:350 )
在线值:
发帖
回帖
粉丝
25
用户中心合并了,登陆接口改变了.
等过段时间更新.
2016-8-28 12:34
0
游客
登录 | 注册 方可回帖
返回
//