[email protected] google data apis - 2009 google data apis : integrando suas aplicações java com...

21
[email protected] Google Data APIs - 2009 http://pcmnac.com Google Data APIs : Integrando suas aplicações Java com os serviços Google

Upload: loreen-stanley

Post on 28-Dec-2015

235 views

Category:

Documents


0 download

TRANSCRIPT

[email protected] Google Data APIs - 2009 http://pcmnac.com

Google Data APIs :Integrando suas aplicações Java com os

serviços Google

[email protected] Google Data APIs - 2009 http://pcmnac.com

Available APIs

source: http://code.google.com/apis/gdata

[email protected] Google Data APIs - 2009 http://pcmnac.com

Practical Usage

• Google data APIs are not read-only!

[email protected] 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)

[email protected] Google Data APIs - 2009 http://pcmnac.com

Application Requirements

• Make HTTP requests – At least GET and POST

• Handle XML messages– JSON can be used

[email protected] 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

[email protected] Google Data APIs - 2009 http://pcmnac.com

GData Protocol

[email protected] Google Data APIs - 2009 http://pcmnac.com

Background

• REST Web Services

• Web Feeds

[email protected] 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)

[email protected] 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

[email protected] Google Data APIs - 2009 http://pcmnac.com

Web Feeds

• Frequently updated content (Wikipedia)• Common Formats

– RSS– Atom (GData default format)

• Feed• Entry

[email protected] 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>[email protected]</email> </author> <title type="text">My Entry</title> <content type="text">My content</content> </entry> <entry> ... </entry></feed>

[email protected] Google Data APIs - 2009 http://pcmnac.com

GData Protocol

• Based on HTTP methods:– POST (Create)– GET (Retrieve)– PUT (Update)– DELETE (Delete)

[email protected] 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:

[email protected] Google Data APIs - 2009 http://pcmnac.com

GData – Creating Data

POST http://www.myservice.com/myfeed

<entry> <author> <name>John</name> <email>[email protected]</email> </author> <title type="text">My Entry</title> <content type="text">My content</content></entry>

Request:

[email protected] 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>[email protected]</email>

</author>

<title type="text">My Entry</title>

<content type="text">My content</content>

</entry>

Response:

[email protected] 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>[email protected]</email> </author> <title type="text">My Entry</title> <content type="text">My content</content></entry>

Request:

[email protected] 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>[email protected]</email>

</author>

<title type="text">My Entry</title>

<content type="text">My content</content>

</entry>

Response:

[email protected] Google Data APIs - 2009 http://pcmnac.com

GData – Deleting Data

DELETE http://myservice.com/myfeed/5/1

Request:

200 OK

Response:

[email protected] Google Data APIs - 2009 http://pcmnac.com

Project 1

Google Contacts Manager

[email protected] Google Data APIs - 2009 http://pcmnac.com

Project 2

Google PDF Converter