pcmnac@gmail.com google data apis - 2009 google data apis : integrando suas aplicações java com...
Post on 28-Dec-2015
235 Views
Preview:
TRANSCRIPT
pcmnac@gmail.com Google Data APIs - 2009 http://pcmnac.com
Google Data APIs :Integrando suas aplicações Java com os
serviços Google
pcmnac@gmail.com Google Data APIs - 2009 http://pcmnac.com
Available APIs
source: http://code.google.com/apis/gdata
pcmnac@gmail.com Google Data APIs - 2009 http://pcmnac.com
Practical Usage
• Google data APIs are not read-only!
pcmnac@gmail.com Google Data APIs - 2009 http://pcmnac.com
Practical Usage
• Manage user’s Gmail contacts programmatically• Synchronize user’s Gmail contacts on a mobile
device• Import user’s Gmail contacts to a social application• Manage user’s Google Calendar events• Backup and share and convert user’s documents• Create and publish Posts• Publish user’s photos and videos• Integrate Google services• Remote repository (Contacts, Events, Documents,
Images, Videos, etc)
pcmnac@gmail.com Google Data APIs - 2009 http://pcmnac.com
Application Requirements
• Make HTTP requests – At least GET and POST
• Handle XML messages– JSON can be used
pcmnac@gmail.com Google Data APIs - 2009 http://pcmnac.com
How it works?
• APIs are available in form of RESTful web services
• There is a well-defined protocol used– Atom based
pcmnac@gmail.com Google Data APIs - 2009 http://pcmnac.com
Background
• REST Web Services
• Web Feeds
pcmnac@gmail.com Google Data APIs - 2009 http://pcmnac.com
REST Web Services
• Based on HTTP methods:– POST (Create)– GET (Retrieve)– PUT (Update)– DELETE (Delete)
• Basic request members:– HTTP Method – Resource URI– Request Body (Optional)
pcmnac@gmail.com Google Data APIs - 2009 http://pcmnac.com
REST Web Services
• Request examples:
HTTP Method Resource URI
GET http://myservice.com/users
GET http://myservice.com/users/5
DELETE http://myservice.com/users/5
POST http://myservice.com/users
PUT http://myservice.com/users/6
pcmnac@gmail.com Google Data APIs - 2009 http://pcmnac.com
Web Feeds
• Frequently updated content (Wikipedia)• Common Formats
– RSS– Atom (GData default format)
• Feed• Entry
pcmnac@gmail.com Google Data APIs - 2009 http://pcmnac.com
Atom Feed Example<feed xmlns="http://www.w3.org/2005/Atom"> <title>My Feed</title> <updated>2008-09-23T08:30:00-03:00</updated> <id>http://www.example.com/myFeed</id> <author> <name>pcmnac</name> </author> <link href="/myFeed" rel="self"/> <entry> <id>http://www.example.com/id/1</id> <link rel="edit" href="http://www.example.com/myFeed/1/1/"/> <updated>2008-09-24T08:30:00-03:00</updated> <author> <name>John</name> <email>john@gmail.com</email> </author> <title type="text">My Entry</title> <content type="text">My content</content> </entry> <entry> ... </entry></feed>
pcmnac@gmail.com Google Data APIs - 2009 http://pcmnac.com
GData Protocol
• Based on HTTP methods:– POST (Create)– GET (Retrieve)– PUT (Update)– DELETE (Delete)
pcmnac@gmail.com Google Data APIs - 2009 http://pcmnac.com
GData – Retrieving DataGET http://www.myservice.com/myfeed
200 OK
<feed xmlns="http://www.w3.org/2005/Atom">
<title>My Feed</title>
<updated>2008-09-23T08:30:00-03:00</updated>
<id>http://www.myservice.com/myfeed</id>
<author>
<name>pcmnac</name>
</author>
<link href="/myfeed" rel="self"/>
<entry>
...
</entry>
</feed>
Request:
Response:
pcmnac@gmail.com Google Data APIs - 2009 http://pcmnac.com
GData – Creating Data
POST http://www.myservice.com/myfeed
<entry> <author> <name>John</name> <email>john@gmail.com</email> </author> <title type="text">My Entry</title> <content type="text">My content</content></entry>
Request:
pcmnac@gmail.com Google Data APIs - 2009 http://pcmnac.com
GData – Creating Data
201 CREATED
<entry>
<id>http://www.myservice.com/myfeed/1</id>
<link rel="edit" href="http://www.myservice.com/myfeed/5/1/"/>
<updated>2008-09-24T08:30:00-03:00</updated>
<author>
<name>John</name>
<email>john@gmail.com</email>
</author>
<title type="text">My Entry</title>
<content type="text">My content</content>
</entry>
Response:
pcmnac@gmail.com Google Data APIs - 2009 http://pcmnac.com
GData – Updating Data
PUT http://www.myservice.com/myfeed/5/1
<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='"CUUEQX47eCp7ImA9WxRVEkQ."'> <id>http://www.myservice.com/myfeed/5</id> <link rel='edit' href='http://www.myservice.com/myfeed/5/1/'/> <updated>2008-09-24T08:30:00-03:00</updated> <author> <name>John</name> <email>john@gmail.com</email> </author> <title type="text">My Entry</title> <content type="text">My content</content></entry>
Request:
pcmnac@gmail.com Google Data APIs - 2009 http://pcmnac.com
GData – Updating Data
200 OK
<entry xmlns='http://www.w3.org/2005/Atom'
xmlns:gd='http://schemas.google.com/g/2005'
gd:etag='"FkkOQgZGeip7ImA6WhVR"'>
<id>http://www.myservice.com/myfeed/5</id>
<link rel='edit' href='http://www.myservice.com/myfeed/5/2/'/>
<updated>2008-09-25T08:30:00-03:00</updated>
<author>
<name>John</name>
<email>john@gmail.com</email>
</author>
<title type="text">My Entry</title>
<content type="text">My content</content>
</entry>
Response:
pcmnac@gmail.com Google Data APIs - 2009 http://pcmnac.com
GData – Deleting Data
DELETE http://myservice.com/myfeed/5/1
Request:
200 OK
Response:
top related