Download presentation
Presentation is loading. Please wait.
Published byCamron Cameron Modified over 9 years ago
1
CS 190 Lecture Notes: Tweeter ProjectSlide 1 Uniform Resource Locators (URLs) http://localhost:8080/friendships/create?my_id=100&user_id=200 Scheme Host Name Port Number Hierarchical portion Query
2
CS 190 Lecture Notes: Tweeter ProjectSlide 2 HTTP GET Request GET /statuses/user_timeline?my_id=100 HTTP/1.1 Host: www.example.com User-Agent: Mozilla/5.0 Accept: text/html, */* Accept-Language: en-us Accept-Charset: ISO-8859-1,utf-8 Connection: keep-alive blank line GET /statuses/user_timeline?my_id=100 HTTP/1.1 Host: www.example.com User-Agent: Mozilla/5.0 Accept: text/html, */* Accept-Language: en-us Accept-Charset: ISO-8859-1,utf-8 Connection: keep-alive blank line URLProtocol VersionMethod Headers Body (empty)
3
CS 190 Lecture Notes: Tweeter ProjectSlide 3 HTTP Response HTTP/1.1 200 OK Date: Thu, 24 Jul 2008 17:36:27 GMT Server: Tweeter/1.0 Content-Type: application/json;charset=UTF-8 Content-Length: 266 blank line {"tweets": [{"id": 20006, "user": 100, "time": "Mon Oct 27 18:02:57 PDT 2014", "text": "I’m at home now",}, {"id": 20005, "user": 100, "time": "Mon Oct 27 17:33:57 PDT 2014", "text": "Stuck in traffic"}... ] } HTTP/1.1 200 OK Date: Thu, 24 Jul 2008 17:36:27 GMT Server: Tweeter/1.0 Content-Type: application/json;charset=UTF-8 Content-Length: 266 blank line {"tweets": [{"id": 20006, "user": 100, "time": "Mon Oct 27 18:02:57 PDT 2014", "text": "I’m at home now",}, {"id": 20005, "user": 100, "time": "Mon Oct 27 17:33:57 PDT 2014", "text": "Stuck in traffic"}... ] } StatusStatus MessageVersion Headers Body
4
CS 190 Lecture Notes: Tweeter ProjectSlide 4 HTTP POST Request POST /statuses/update HTTP/1.1 Host: www.example.com User-Agent: Mozilla/5.0 Accept: text/html, */* Accept-Language: en-us Accept-Charset: ISO-8859-1,utf-8 Connection: keep-alive blank line my_id=100&status=Stuck%20in%20traffic POST /statuses/update HTTP/1.1 Host: www.example.com User-Agent: Mozilla/5.0 Accept: text/html, */* Accept-Language: en-us Accept-Charset: ISO-8859-1,utf-8 Connection: keep-alive blank line my_id=100&status=Stuck%20in%20traffic URLProtocol VersionMethod Headers Body (form data) Parameters
5
● Simple values: "This is a string" 99.6 ● Arrays: [14, 32, "California", 1.001] ● Objects (named properties): {"name": "Alice", "age": 24, "salary": 145000} ● Nested values: {"name": "Alice", "gpa": 3.5, "friends": ["Bill", "Carol", "David"]} CS 190 Lecture Notes: Tweeter ProjectSlide 5 JSON Notation
6
POST /friendships/create?my_id=100&user_id=200 User 100 becomes a follower of user 200 POST /friendships/destroy?my_id=100&user_id=200 User 100 is no longer a follower of user 200 GET /friends/ids.json?user_id=100 Return ids for all users that user 100 is following: [100, 84, 290, 16] GET /followers/ids.json?user_id=100 Return ids for all the users following user 100: [200, 374, 82, 95, 1003] CS 190 Lecture Notes: Tweeter ProjectSlide 6 Tweeter Interface
7
POST /statuses/update?my_id=100&status=Sleepy Create a new tweet for user 100 GET /statuses/user_timeline.json?my_id=100 &count=20&max_id=25000 Return the 20 most recent tweets from user 100 (exclude tweets with ids > 25000) {"tweets": [{"id": 20006, "user": 100, "time": "Mon Oct 27 18:02:57 PDT 2014", "text": "I’m at home now"}, {"id": 20005, "user": 100, "time": "Mon Oct 27 17:33:57 PDT 2014", "text": "Stuck in traffic"}... ] } CS 190 Lecture Notes: Tweeter ProjectSlide 7 Tweeter Interface, cont’d
8
GET /statuses/home_timeline.json?my_id=100 &count=10&max_id=25000 Return the 20 most recent tweets from user 100 and all users followed by user 100 (exclude tweets with ids > 25000) CS 190 Lecture Notes: Tweeter ProjectSlide 8 Tweeter Interface, cont’d
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.