RSS Feed

Tags

Archives

Categories

Recent Posts

Links

Curl and google data api

March 4th, 2011 by D in Google, howto, Tech

Authorization :

curl -d accountType=HOSTED -d Email=youruser\@yourdomain -d Passwd=yourpassword -d service=jotspot -d source=yoursource https://www.google.com/accounts/ClientLogin
Then grab the Auth token from this

Communication (creating new page as example) :

First create the “payload” in a file, here is a payload example (this is the request to create a new page)

<entry xmlns=”http://www.w3.org/2005/Atom”>
<category scheme=”http://schemas.google.com/g/2005#kind”
term=”http://schemas.google.com/sites/2008#webpage” label=”webpage”/>
<title>New Webpage Title</title>
<content type=”xhtml”>
<div xmlns=”http://www.w3.org/1999/xhtml”>HTML body goes here</div>
</content>
</entry>

Then create the request

curl -v -H ‘Content-Type: application/atom+xml’ -H ‘GData-Version: 1.0′ -H ‘Authorization: GoogleLogin auth=”your auth token“‘ -d ‘@file’  https://sites.google.com/feeds/content/yourdomain/page

Then go read the google API documentation for more fun!