GData "Greetings, program!"
·——
····
··
—
·····
···——
——···
After
installing the new GData Python library, here is a
Greetings, program! script that posts to Blogger, and here are some lessons learned:
- GData (Atom?) operates primarily on feeds. When the API calls for a service URI, that is the URI of your feed, and creating new items means inserting them into that feed.
- Start with
gdata_service.GDataService. There are specialized subclasses for Base, Calendar, and Spreadsheets. There isn't one for Blogger, probably because Blogger is basically straight Atom.
- Use the classes in the
atom module to construct blog entries, but note that the API is goofy. For example, here's how to construct an author: Author(name=Name(text="Chad")). Also, an Entry's author argument/attribute is actually a list of Author instances, not a single Author. Etc.
- For the "Greetings, program!" script you'll need your blog's ID, which you can grab from just about any querystring when managing your blog using the Blogger dashboard. In general you can also post using a blogspot.com subdomain, or presumably a hosted custom domain.
- If you need to see an HTML error page, capture
gdata_service.RequestError, print exc.args[0]['body'] to a file, then open it in your web browser. Usually, though, such messages are too generic to be helpful.
- As usual, RTFM (both the API docs and the general GData docs), refer to the tests and samples bundled with the distribution, and use the source when necessary.
Gdata-python-client is quirky, but once you get oriented you realize how powerful it is. Hopefully over time they/we can smooth it out with some even higher-level APIs.
·——
····
··
—
·····
···——
——···
Feed back to
Chad Whitacre.