I have collected quite a few URLs in my experimenting. I won't bother explaining GET parameters (those ?var=value&var2=value2 things in some URLs) or whatever they are called. I'll just spit out the information, so I hope you're a bit tech-savvy!
BlogSpot provides feeds in Atom and RSS. By default, it uses Atom, but this can be changed to RSS by passing the parameter "alt=rss".
Getting a list of blogs by user
- You can get a list of blogs by the currently signed-in user with the following URL:
http://www.blogger.com/feeds/default/blogs/ - You can get a list of blogs by another user with the following URL:
http://www.blogger.com/feeds/$user_id/blogs/
$user_id is the user id of the user. This can be found by going to their profile and copying the numbers from that.
This method, however, seems to be disabled for most blogs. I wouldn't rely upon it.
Getting a blog id (needed for much of the stuff below)
- If you got the metafeed above to work, it is in the feed->entry->id XML tag (the last number after the dash).
- It can also be found in the source code of a blog. Just do a quick search for "blogID=".
- Most easily, your own blog id can be found in the URL when you go to your blog in Blogger's Dashboard.
Getting a list of posts by blog
- To get a list of posts of a blog, the following URLs can be used
- http://www.blogger.com/feeds/$blog_id/posts/default
- http://${username}.blogspot.com/feeds/posts/default
- Examples:
- http://www.blogger.com/feeds/8868635167022412568/posts/default
- http://nathanbelue.blogspot.com/feeds/posts/default
- The above feeds will either show a summary of posts or the full posts. It depends on the settings that the user has set for the blog. For a programmer, uncertainty is horrible, but don't fret because there is a way to specify which you want.
The "default" at the end can be changed to specify the length of what is returned - "full" - Display the entire posts in the feed.
- "summary" - Display a summary of the posts in the feed.
- Filtering by label (category, tag, whatever you call it) can also be done.
Just add "/-/$filters" to the end of the URLs, after the "default" (or "summary" or "full").
Here is an example that will filter my posts by those about allocators:
http://nathanbelue.blogspot.com/feeds/posts/summary/-/allocator
Here's another example that will only return posts on both red-black and AVL trees.
http://nathanbelue.blogspot.com/feeds/posts/full/-/avl%20tree/red-black%20tree
The labels are case-sensitive. - Restricting the number of results, sorting, specifying a date range, and getting another page of results can all be done via GET parameters.
- start-index - Which page of results to get (starting at 1)
- max-index - The maximum number of results per page.
- published-min - The minimum date (YYYY-MM-DDThh:mm:ss)
- published-max - The maximum date (YYYY-MM-DDThh:mm:ss)
- orderby - The ordering. Can be "published" or "updated".
- Final example:
- http://nathanbelue.blogspot.com/feeds/posts/summary/-/avl%20tree?published-min=2012-05-01T00:00:00&published-max=2012-05-11T00:00:00&orderby=updated
- http://www.blogger.com/feeds/8868635167022412568/posts/summary/-/avl%20tree?published-min=2012-05-01T00:00:00&published-max=2012-05-11T00:00:00&orderby=updated
Getting a post id (needed for much of the stuff below)
- The post id can be found in the feed given by the post list above.
- The last number (after the "-") of feed->entry->id
- The last number in the URL in the href attribute of the feed->entry->link tag that also has the rel attribute set to "self" (also, on the one set to "edit").
- It can also be found in the source code of a blog post (do a quick search for "PostID=").
- Most easily, it can be found when editing a post (look in the URL).
- While we're on this, also note that the friendly URL can be obtained from the feed in the href attribute of the feed->entry->link tag that has the rel attribute set to "alternate".
Getting a list of comments by post
- To get the comments of a post, the following URL can be used:
http://${username}.blogspot.com/feeds/$post_id/comments/default
Sorry, but the username must be known for this one. You can, however, get a list of all of the comments in a blog via the following URL:
http://www.blogger.com/feeds/$blog_id/comments/default
The later URL will even return comments of some deleted posts. That makes it ill-suited for some purposes but very useful for others. }:-) - Changing default to "summary" or "full" is supported, but it doesn't seem to make much of a difference. (Can comments have summaries?)
It might be a good idea to nevertheless specify which you want (don't use the default). - The following GET parameters are supported:
- start-index - The page of results to get (starts at 1)
- max-results - The maximum number of results to get
- The comment feed does not seem to support sorting or filtering. Also, the maximum number of results that can be returned is a measly 200.
To get more than 200, you'll have to start with start-index=1&max-results=200, then get the next page with start-index=201&max-results=200. Keep repeating that until the value of the feed->openSearch:totalResults tag in the XML file is not equal to the value of the feed->openSearch:itemsPerPage tag. - Comments can be in response to other comments. If this is the case, then a comment entry has an additional link tag with a rel="related" attribute and a href attribute set to the URL specified in the related comment's href attribute of the link tag with a rel="self" attribute.
In the feed, however, a response to a comment will come before the comment. This makes programming something to group them together rather difficult.
More information and help
http://xmlbeautifier.com/ has proven to anindispensabletool in my working with XML. I plan to one-up it soon (adding some features that would help me), but it's wonderful until then.
https://developers.google.com/blogger/docs/1.0/reference is some reference material on the above.
https://developers.google.com/blogger/docs/1.0/developers_guide_php has a bit of information that can be applied to the above.
If you search for my blog interface source code in the downloads of my website (http://www.nathanbelue.com), it has some useful source code in it, including a PHP file that can get all of the comments of a post and return them in various ways.
No comments:
Post a Comment