ruby を使って google picasa web API を呼び出してみる。
require 'net/https'
http = Net::HTTP.new('www.google.com', 443)
http.use_ssl = true
path = '/accounts/ClientLogin'
data = 'accountType=HOSTED_OR_GOOGLE&Email=USER-ID@gmail.com&Passwd=XXXXX&service=lh2'
headers = { 'Content-Type' => 'application/x-www-form-urlencoded'}
resp, resbody = http.post(path, data, headers)
cl_string = resbody[/Auth=(.*)/, 1]
headers["Authorization"] = "GoogleLogin auth=#{cl_string}"
picasa = Net::HTTP.new('picasaweb.google.com', 80)
resp, resbody = picasa.get('/data/entry/api/user/USER-ID', headers)
resp, resbody = picasa.get('/data/feed/api/user/USER-ID', headers)
postheaders = {'content-type', 'application/atom+xml; charset=UTF-8'}
postheaders["Authorization"] = "GoogleLogin auth=#{cl_string}"
body_new_album = ' Trip To JP JJJ. Italy public true 1152255600000 italy, vacation '
resp, resbody = picasa.post('/data/feed/api/user/USER-ID', body_new_album, postheaders)
putbody = 'xxx'
req = Net::HTTP::Put.new('/data/entry/api/user/chocolat.kurokawa/albumid/ALBUM-ID/VERSION-ID')
req['Authorization'] = "GoogleLogin auth=#{cl_string}"
req['content-type'] = 'application/atom+xml'
res = picasa.request(req, putbody)
resp.canonical_each{|name,value|
p name + ': ' + value
}
file = File.open("/mnt/c/tmp/response.xml", 'w')
file << resbody
file.close