jweibo: an sdk solution for sina weibo restful open api mentor: dai yintao student: deng litao date:...
TRANSCRIPT
![Page 1: JWeiBo: an SDK Solution for Sina WeiBo RESTful Open API Mentor: Dai Yintao Student: Deng Litao Date: 06/08/2011 北京理工大学本科生毕业设计答辩](https://reader031.vdocuments.net/reader031/viewer/2022012306/56649e685503460f94b63d53/html5/thumbnails/1.jpg)
JWeiBo: an SDK Solution for Sina WeiBo RESTful Open API
Mentor: Dai Yintao
Student: Deng Litao
Date: 06/08/2011
北京理工大学本科生毕业设计答辩
![Page 2: JWeiBo: an SDK Solution for Sina WeiBo RESTful Open API Mentor: Dai Yintao Student: Deng Litao Date: 06/08/2011 北京理工大学本科生毕业设计答辩](https://reader031.vdocuments.net/reader031/viewer/2022012306/56649e685503460f94b63d53/html5/thumbnails/2.jpg)
Outline
1. Background
2. Related work
3. Requirement
4. Design
5. Implementation
6. Sample codes
7. Future work
![Page 3: JWeiBo: an SDK Solution for Sina WeiBo RESTful Open API Mentor: Dai Yintao Student: Deng Litao Date: 06/08/2011 北京理工大学本科生毕业设计答辩](https://reader031.vdocuments.net/reader031/viewer/2022012306/56649e685503460f94b63d53/html5/thumbnails/3.jpg)
Background
Microblogging’s bombing development Increasing demands for third-party applications.
Microblogging’s characters
![Page 4: JWeiBo: an SDK Solution for Sina WeiBo RESTful Open API Mentor: Dai Yintao Student: Deng Litao Date: 06/08/2011 北京理工大学本科生毕业设计答辩](https://reader031.vdocuments.net/reader031/viewer/2022012306/56649e685503460f94b63d53/html5/thumbnails/4.jpg)
Background
1: The base URL (or URI) for the Web Services.2: The Internet media type for the data supported by the Web
Services, XML and JSON.3: The set of operations of HTTP methods defined on the
resources, such as GET, POST, PUT and DELETE.
RESTful Web Services
![Page 5: JWeiBo: an SDK Solution for Sina WeiBo RESTful Open API Mentor: Dai Yintao Student: Deng Litao Date: 06/08/2011 北京理工大学本科生毕业设计答辩](https://reader031.vdocuments.net/reader031/viewer/2022012306/56649e685503460f94b63d53/html5/thumbnails/5.jpg)
Related Work
1: Request from outside. 2: Data demand from Controller to Model.
3: Data interchange between application and Sina WeiBo. 4: Data from Model to Controller. 5: Data from Controller to View.
6: Response to outside.
JWeiBo’s role
![Page 6: JWeiBo: an SDK Solution for Sina WeiBo RESTful Open API Mentor: Dai Yintao Student: Deng Litao Date: 06/08/2011 北京理工大学本科生毕业设计答辩](https://reader031.vdocuments.net/reader031/viewer/2022012306/56649e685503460f94b63d53/html5/thumbnails/6.jpg)
Requirement
1: The request parameters could be viewed as the input. 2: Initializing the HTTP call.
3: Invoke the HTTP call by specified scheme. Finally, the HTTP headers and body can be used as the output.
Data flow in swim lane
Function
![Page 7: JWeiBo: an SDK Solution for Sina WeiBo RESTful Open API Mentor: Dai Yintao Student: Deng Litao Date: 06/08/2011 北京理工大学本科生毕业设计答辩](https://reader031.vdocuments.net/reader031/viewer/2022012306/56649e685503460f94b63d53/html5/thumbnails/7.jpg)
Design
1: Initializing API. 2: Constructing Request. 3: HTTP Transaction. 4: Fetching Response.
Architecture of JWeiBo
![Page 8: JWeiBo: an SDK Solution for Sina WeiBo RESTful Open API Mentor: Dai Yintao Student: Deng Litao Date: 06/08/2011 北京理工大学本科生毕业设计答辩](https://reader031.vdocuments.net/reader031/viewer/2022012306/56649e685503460f94b63d53/html5/thumbnails/8.jpg)
Design
Program interface between classes
![Page 9: JWeiBo: an SDK Solution for Sina WeiBo RESTful Open API Mentor: Dai Yintao Student: Deng Litao Date: 06/08/2011 北京理工大学本科生毕业设计答辩](https://reader031.vdocuments.net/reader031/viewer/2022012306/56649e685503460f94b63d53/html5/thumbnails/9.jpg)
Implementation
HTTPManager(SinaWeiBoHTTPManager)
HTTP Basic:encodedBasic="Basic"+new String(new
BASE64Encoder().encode((credential.getUsername() +":"+ credential.getPassword()).getBytes()));
httpGet.addHeader("Authorization", encodedBasic);
HTTP
![Page 10: JWeiBo: an SDK Solution for Sina WeiBo RESTful Open API Mentor: Dai Yintao Student: Deng Litao Date: 06/08/2011 北京理工大学本科生毕业设计答辩](https://reader031.vdocuments.net/reader031/viewer/2022012306/56649e685503460f94b63d53/html5/thumbnails/10.jpg)
Implementation
HTTPManager(SinaWeiBoHTTPManager)
OAuth:
HTTP
Steps in OAuth authentication
![Page 11: JWeiBo: an SDK Solution for Sina WeiBo RESTful Open API Mentor: Dai Yintao Student: Deng Litao Date: 06/08/2011 北京理工大学本科生毕业设计答辩](https://reader031.vdocuments.net/reader031/viewer/2022012306/56649e685503460f94b63d53/html5/thumbnails/11.jpg)
Implementation
Response(SinaWeiBoResponse)
Data format:XML, JSON.
Ultimate Container:JavaBean (Status, User, Comment, Emotion……).
private long id, String screen_name;public void assignXML(Element elem), assignJSON(JSONObject jsonObject){}public static List<User> parseXML(Document document), parseJSON(JSONArray jsonArray){}public static User parseXMLAsElement(Document document), parseJSONAsObject(JSONObject jsonObject)public static List<User> parseJSONAsHybrid(JSONObject jsonObject){@Override public String toString(), boolean equals(Object object), int hashCode()
Response
![Page 12: JWeiBo: an SDK Solution for Sina WeiBo RESTful Open API Mentor: Dai Yintao Student: Deng Litao Date: 06/08/2011 北京理工大学本科生毕业设计答辩](https://reader031.vdocuments.net/reader031/viewer/2022012306/56649e685503460f94b63d53/html5/thumbnails/12.jpg)
Sample codes
Source Code:
api = SinaWeiBo.builder().initialize(appKey,appSecret).build();request = ((SinaWeiBo)api).publicTimeline().count(10).build();response = request.httpCall();System.out.println(response.toString());
statuses = PublicTimeline.parser(response).parse();for(Status status : statuses){
System.out.println(status.toString());}
Output:
XML JSON
![Page 13: JWeiBo: an SDK Solution for Sina WeiBo RESTful Open API Mentor: Dai Yintao Student: Deng Litao Date: 06/08/2011 北京理工大学本科生毕业设计答辩](https://reader031.vdocuments.net/reader031/viewer/2022012306/56649e685503460f94b63d53/html5/thumbnails/13.jpg)
Acknowledgments
It has been a great pleasure to work with my advisor Dai Yintao, during the course E-Commerce and the graduation project; he impressed me a lot by his critical thinking and kindness.
Zhao Fengnian also deserves a great of thanks, for he introduced me to the Web Technology and led to all of the work I have done about the applications and systems on network.
I would like to thank all of my classmates who accompanied me through the graduation project; you gave me so many strong encouragements and selfless cares.