Tipping, Not Just For Cows and Waitresses
August 28th, 2008 | Published in Google Code
We field all kinds of questions in the discussion groups, usually resulting in small snippets of code that aren't easy for other people to find. So we decided to start up a Tips Blog for all the Google Data APIs.
For example, do you know how to perform a GET with a POST? Since Flash doesn't allow a custom Authorization header on a GET, sometimes you need to do a GET with a POST using the X-HTTP-Method-Override header. Here it is in action, performing a search for kitten videos using the YouTube Data API:
POST /feeds/api/videos HTTP/1.1
Host: gdata.youtube.com
X-HTTP-Method-Override: GET
Content-Length: 23
Content-Type: application/x-www-form-urlencoded
vq=kitten&max-results=1
This is the same as performing a GET on http://gdata.youtube.com/feeds/api/videos?vq=kitten&max-results=1. The POST body is used as the set of query parameters. You can also do this using the curl command:
curl -H "X-HTTP-Method-Override: GET" -X POST http://gdata.youtube.com/feeds/api/videos -d "vq=kitten&max-results=1"
Want to subscribe to tips for your favorite API? Blogger (since it's a Google Data API, naturally) allows you to use the category filters to customize the feed and throw it into your feed reader of choice. For example, to get all tips for YouTube, use:
http://gdatatips.blogspot.com/feeds/posts/default/-/youtube
If you only want PHP tips for YouTube, you can further filter the labels:
http://gdatatips.blogspot.com/feeds/posts/default/-/youtube/php
Or, of course, you can subscribe to the whole thing by just using the base feed:
http://gdatatips.blogspot.com/feeds/posts/default/