BloggerApi.getRecentPosts (appkey, blogid, username, password, numberOfPosts)
blogger.getRecentPosts returns a list of the most recent posts in the system

  • Parameter appkey:
    String
  • Parameter blogid:
    String
  • Parameter username:
    String
  • Parameter password:
    String
  • Parameter numberOfPosts:
    int, default 20
  • Returns
    Array of Objects representing Blog Entries with the following properties .userid String .postid String .dateCreated Date .content String
Sourcecode in BloggerApi/bloggerAPI.js:
1:   function getRecentPosts(appkey, blogid, username, password, numberOfPosts) {
2:      var usr = root.blogger.getUser(username, password);
3:      var blog = root.blogger.getBlog(blogid.toString());
4:      if (!blog)
5:         throw("Couldn't find the blog " + blogid);
6:      var level = blog.members.getMembershipLevel(usr);
7:      try {
8:         blog.checkView(usr, level);
9:      } catch (deny) {
10:        throw("You're not allowed to view the blog " + blogid);
11:     }
12:  
13:     var size = blog.stories.size();
14:     var limit = Math.min(numberOfPosts ? Math.min(numberOfPosts, 20) : 20, size);
15:     var posts = new Array();
16:     var idx = 0;
17:     while (posts.length < limit && idx < size) {
18:        var entry = blog.stories.get(idx++);
19:        try {
20:           entry.checkEdit(usr, level);
21:        } catch (deny) {
22:           continue;
23:        }
24:        var param = new Object();
25:        param.postid = entry._id;
26:        param.userid = entry.creator.name;
27:        param.dateCreated = entry.createtime;
28:        if (entry.title)
29:           param.content = "<title>"+entry.title+"</title>"+
30:               entry.content.getProperty("text");
31:        else
32:           param.content = entry.content.getProperty("text");
33:        posts[posts.length] = param;
34:     }
35:     return posts;
36:  }