Google Developer REST API Examples by cURL.
- Refresh Token
- refresh_token等の取得方法はGoogle API OAuth2.0のアクセストークン&リフレッシュトークン取得手順メモ - Qiita を参考に。
curl -X POST https://accounts.google.com/o/oauth2/token \
-d client_id=${CLIENT_ID} \
-d client_secret=${CLIENT_SECRET} \
-d refresh_token=${REFRESH_TOKEN} \
-d grant_type=refresh_token
{
"access_token" : "xxxxx.xxxxxxx-xxxxxx-xxxxx-xxx",
"token_type" : "Bearer",
"expires_in" : 3600
}
curl -X GET https://picasaweb.google.com/data/feed/api/user/${USER_ID} \
-H "Content-Type: application/atom+xml" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "GData-Version: 2"
curl -X POST https://picasaweb.google.com/data/feed/api/user/${USER_ID} \
-H "Content-Type: application/atom+xml" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "GData-Version: 2" \
-d "<entry xmlns='http://www.w3.org/2005/Atom' \
xmlns:media='http://search.yahoo.com/mrss/' \
xmlns:gphoto='http://schemas.google.com/photos/2007'> \
<title type='text'>Title of the Album</title> \
<category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/photos/2007#album'></category> \
</entry>"
curl -X GET https://picasaweb.google.com/data/feed/api/user/${USER_ID}/albumid/${ALBUM_ID} \
-H "Content-Type: application/atom+xml" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "GData-Version: 2"
- Update a Photo
- Only the metadata
curl -X PUT https://picasaweb.google.com/data/entry/api/user/${USER_ID}/albumid/${ALBUM_ID}/photoid/${PHOTO_ID} \
-H "Content-Type: application/atom+xml" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "GData-Version: 2" \
-H "If-Match: *" \
-d '<entry xmlns="http://www.w3.org/2005/Atom" \
xmlns:media="http://search.yahoo.com/mrss/"> \
<media:group><media:keywords>タグ1, タグ2, タグ3</media:keywords> \
</media:group> \
</entry>'