微博客户端开发
本周学习计划
- 运用OAuth相关知识,解决上周出现的微博验证问题。
- 看懂微博客户端登录、用户主页等功能代码。
- 将程序中存在的问题解决。
实际完成情况
-
本周继续研究了OAuth相关知识,解决了授权问题。
- 系统授权模块
微博采用Oauth授权机制,将申请的开发者APPID和APPSK传入Auth()方法中,获取从授权页面获得的授权码Access Token。程序跳转到登录界面,用户输入用户名和密码之 后,客户端会完成授权认证的第三部,获得TokenKey和TokenSecrect,从而获得获取用户信息的权限。授权认证的核心代码为:
path = "https://open.t.qq.com/cgi-bin/oauth2/authorize?
client_id="+ clientId+ "&response_type=
token&redirect_uri="redirectUri + "&state=" + state;
获取授权后的返回地址,并对其进行解析 jumpResultParser(String result)
2.系统其它功能模块设计与研究
- 登录模块
当用户授权成功后就会跳转到登录界面,通过authorize调用接口,调入用户登陆界面,并保存用户有关信息(access_toekn、user_id、user_name)。
用户登录页面,需输入用户名和密码,如图:
- 用户首页模块
当用户登录成功后就会打开LoginActivity.在这个Activity中,主要是一个ListView,在ListView中的每一个条目中展示每一条微博。
首页显示用户动态信息,如图:
进度计划
1.第四周
继续研究微博撰写、发布等功能模块,根据老师建议添加修改功能,完成项目报告。
2.第五周
进行测试,并进行优化。