GData ver. 2 & Curl - Partial update using Oauth version 2 . Add georss:where to photos


/ Published in: Bash
Save to your folder(s)

using Docs for gdata v 2 api

per the docs, there are multiple requests required and there are ETAG dependencies

in the partial update, the contents of the file 'add-geo' are added to the entity


Copy this code and paste it in your HTML
  1. file content 'add-geo'... used for partial update on <georss:where/>
  2.  
  3. <?xml version='1.0' encoding='UTF-8' ?><entry xmlns='http://www.w3.org/2005/Atom'
  4. xmlns:gd="http://schemas.google.com/g/2005" xmlns:georss="http://www.georss.org/georss"
  5. xmlns:gml="http://www.opengis.net/gml" gd:fields="georss:where">
  6. <georss:where><gml:Point><gml:pos>61.104 -149.580</gml:pos></gml:Point></georss:where></entry>
  7.  
  8. --- use oauth access token retreived using playgroud
  9. --- get the link rel='edit' URL needed for the partial update on the photo entry...
  10.  
  11. $ curl -i -k --header "GData-Version: 2" --header "Authorization: OAuth ya29.AHES6ZSridqaPo0vR4ZJ3vfl1BzcuKCxs8cVlzW1XOytQ5Syl6iROw"
  12. https://picasaweb.google.com/data/feed/api/user/rowntreerob/albumid/5657647416240712401/photoid/5657647761010952722?
  13. fields=link%5B%40rel%3D%22edit%22%5D,gd:*
  14.  
  15. HTTP/1.1 200 OK
  16. Expires: Mon, 26 Dec 2011 02:01:50 GMT
  17. Date: Mon, 26 Dec 2011 02:01:50 GMT
  18. Cache-Control: private, max-age=0, must-revalidate, no-transform
  19. Set-Cookie: _rtok=yHEV0BiXvUvr; Path=/; Secure; HttpOnly
  20. Set-Cookie: S=photos_html=REzh7Zgo3q97CH1xEmu8pw; Domain=.google.com; Path=/; Secure; HttpOnly
  21. Content-Type: application/atom+xml; charset=UTF-8; type=feed
  22. Vary: Accept, X-GData-Authorization, GData-Version, Cookie
  23. GData-Version: 2.0
  24. ETag: W/"DUEEQX47eCp7ImA9WhRXGEg." /* unable to match this in the subsequent If-Match header */
  25. Last-Modified: Mon, 26 Dec 2011 00:00:00 GMT
  26. X-Content-Type-Options: nosniff
  27. X-Frame-Options: SAMEORIGIN
  28. X-XSS-Protection: 1; mode=block
  29. Server: GSE
  30. Transfer-Encoding: chunked
  31.  
  32. <?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom'><link rel='edit' type='application/atom+xml' href='https://picasaweb.google.com/
  33. data/entry/api/user/rowntreerob/albumid/5657647416240712401/photoid/5657647761010952722'/></feed>
  34.  
  35. ---- PATCH the above link with contents of the file...
  36. ---- NOTE: may have to use rel='self' and NOT the rel='edit' link as shown
  37.  
  38. $ curl -X PATCH -k -i --upload-file add-geo --header "X-HTTP-Method-Override: PATCH"
  39. --header "GData-Version: 2" --header
  40. 'Authorization: OAuth ya29.AHES6ZSridqaPo0vR4ZJ3vfl1BzcuKCxs8cVlzW1XOytQ5Syl6iROw'
  41. --header "If-Match: *" --header "Content-Type: application/xml"
  42. https://picasaweb.google.com/data/entry/api/user/rowntreerob/albumid/5657647416240712401/photoid/5657647761010952722
  43.  
  44. HTTP/1.1 200 OK
  45. Expires: Mon, 26 Dec 2011 02:07:07 GMT
  46. Date: Mon, 26 Dec 2011 02:07:07 GMT
  47. Cache-Control: private, max-age=0, must-revalidate
  48. Set-Cookie: _rtok=c8UtMEhJeoZ3; Path=/; Secure; HttpOnly
  49. Set-Cookie: S=photos_html=LqWrxAvs7iRXYFqKQ3GKsg; Domain=.google.com; Path=/; Secure; HttpOnly
  50. Content-Type: application/atom+xml; charset=UTF-8; type=entry
  51. GData-Version: 2.0
  52. ETag: "YD8qeyI."
  53. X-Content-Type-Options: nosniff
  54. X-Frame-Options: SAMEORIGIN
  55. X-XSS-Protection: 1; mode=block
  56. Server: GSE
  57. Transfer-Encoding: chunked
  58.  
  59. <?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' xmlns:exif='http://schemas.google.com/photos/exif/2007' xmlns:app='http://www.w
  60. 3.org/2007/app' xmlns:gphoto='http://schemas.google.com/photos/2007' xmlns:media='http://search.yahoo.com/mrss/' xmlns:gd='http://schemas.google.com/g/2005' xml
  61. ns:gml='http://www.opengis.net/gml' xmlns:georss='http://www.georss.org/georss' gd:etag='&quot;YD8qeyI.&quot;'><id>https://picasaweb.google.com/data/entry/user/
  62. rowntreerob/albumid/5657647416240712401/photoid/5657647761010952722</id><published>2011-09-29T05:22:49.000Z</published><updated>2011-12-26T02:07:08.115Z</update
  63. d><app:edited>2011-12-26T02:07:08.115Z</app:edited><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/photos/2007#photo'/>
  64. <title>ac01.jpg</title><summary/><content type='image/jpeg' src='https://lh5.googleusercontent.com/-hhk3yNxAYBM/ToQAqcNXihI/AAAAAAAACq0/Xw3QOe7cBt8/ac01.jpg'/><
  65. link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://picasaweb.google.com/data/feed/api/user/rowntreerob/albumid/565764741
  66. 6240712401/photoid/5657647761010952722'/><link rel='alternate' type='text/html' href='https://picasaweb.google.com/113172267863552078400/Ak_sunset_up_hi_up_clos
  67. e#5657647761010952722'/><link rel='http://schemas.google.com/photos/2007#canonical' type='text/html' href='https://picasaweb.google.com/lh/photo/xkTV2bpa8hR1ijh
  68. QoDoGINMTjNZETYmyPJy0liipFm0'/><link rel='self' type='application/atom+xml' href='https://picasaweb.google.com/data/entry/api/user/rowntreerob/albumid/565764741
  69. 6240712401/photoid/5657647761010952722'/><link rel='edit' type='application/atom+xml' href='https://picasaweb.google.com/data/entry/api/user/rowntreerob/albumid
  70. /5657647416240712401/photoid/5657647761010952722'/><link rel='edit-media' type='image/jpeg' href='https://picasaweb.google.com/data/media/api/user/rowntreerob/a
  71. lbumid/5657647416240712401/photoid/5657647761010952722'/><link rel='http://schemas.google.com/photos/2007#report' type='text/html' href='https://picasaweb.googl
  72. e.com/lh/reportAbuse?uname=rowntreerob&amp;aid=5657647416240712401&amp;iid=5657647761010952722'/><gphoto:id>5657647761010952722</gphoto:id><gphoto:albumid>56576
  73. 47416240712401</gphoto:albumid><gphoto:access>public</gphoto:access><gphoto:width>1361</gphoto:width><gphoto:height>916</gphoto:height><gphoto:size>1266131</gph
  74. oto:size><gphoto:checksum>8b1a4092</gphoto:checksum><gphoto:timestamp>126273600000</gphoto:timestamp><gphoto:imageVersion>2733</gphoto:imageVersion><gphoto:comm
  75. entingEnabled>true</gphoto:commentingEnabled><gphoto:commentCount>0</gphoto:commentCount><gphoto:license id='0' name='All Rights Reserved' url=''>ALL_RIGHTS_RES
  76. ERVED</gphoto:license><gphoto:viewCount>2</gphoto:viewCount><exif:tags><exif:make>Nikon</exif:make><exif:model>LS-4000</exif:model><exif:time>126273600000</exif
  77. :time><exif:imageUniqueID>be843f6c37732943ee24194cddbb3f94</exif:imageUniqueID></exif:tags><media:group><media:content url='https://lh5.googleusercontent.com/-h
  78. hk3yNxAYBM/ToQAqcNXihI/AAAAAAAACq0/Xw3QOe7cBt8/ac01.jpg' height='345' width='512' type='image/jpeg' medium='image'/><media:credit>Robert Rowntree</media:credit>
  79. <media:description type='plain'/><media:keywords/><media:thumbnail url='https://lh5.googleusercontent.com/-hhk3yNxAYBM/ToQAqcNXihI/AAAAAAAACq0/Xw3QOe7cBt8/s72/a
  80. c01.jpg' height='49' width='72'/><media:thumbnail url='https://lh5.googleusercontent.com/-hhk3yNxAYBM/ToQAqcNXihI/AAAAAAAACq0/Xw3QOe7cBt8/s144/ac01.jpg' height=
  81. '97' width='144'/><media:thumbnail url='https://lh5.googleusercontent.com/-hhk3yNxAYBM/ToQAqcNXihI/AAAAAAAACq0/Xw3QOe7cBt8/s288/ac01.jpg' height='194' width='28
  82. 8'/><media:title type='plain'>ac01.jpg</media:title></media:group><georss:where><gml:Point><gml:pos>61.104 -149.58</gml:pos></gml:Point></georss:where></entry>

URL: http://code.google.com/apis/gdata/docs/2.0/reference.html#PartialUpdate

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.