Editing contact photos using curl


You can use curl to modify Contacts API contact photos from the command line.

To start, you'll need to get the photo edit link from the contacts feed. This is expressed in the feed as the following XML element:

<link rel="http://schemas.google.com/contacts/2008/rel#photo-edit type="image/*" href="http://www.google.com/m8/feeds/photos/media/user/id/version" />

The photo edit link is contained inside the href attribute. For this example, it would be http://www.google.com/m8/feeds/photos/media/user/id/version.

Once you have this, you can add or update a photo by running:

curl -H "Authorization: GoogleLogin ..." \
-H "Content-Type: image/jpeg" \
-X PUT \
--binary-data "@/path/to/image.jpg" \
http://www.google.com/m8/feeds/photos/media/user/id/version

Be sure to replace the Content-Type and file path with appropriate values for your new photo.

To delete a photo, run:

curl -H "Authorization: GoogleLogin ..." \
-X DELETE \
http://www.google.com/m8/feeds/photos/media/user/id/version

You'll need to make sure that the Authorization header contains a valid ClientLogin token, as explained in the tip "Perform ClientLogin using curl.

No comments: