Skip to content

Instantly share code, notes, and snippets.

@ryo-murai
Last active April 1, 2016 08:42
Show Gist options
  • Save ryo-murai/2a780af320ffd36db063 to your computer and use it in GitHub Desktop.
Save ryo-murai/2a780af320ffd36db063 to your computer and use it in GitHub Desktop.
Google Developer API

Google Developer REST API Examples

Google Developer REST API Examples by cURL.

OAuth 2.0

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" 
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>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment