MetaWeblogApi.newPost (blogid, username, password, content, publish)
metaWeblog.newPost creates a new post, and optionally publishes it

  • Parameter blogid:
    String
  • Parameter username:
    String
  • Parameter password:
    String
  • Parameter content:
    Object, which can contain the following properties .title String .description String .dateCreated String (ISO.8601) .categories Array of Strings, containing categories .flNotOnHomePage Boolean, if true then entry just appears in topic .mt_allow_comments int, 0=no, 1=yes [MT-API] .mt_allow_pings int, currently ignored [MT-API] .mt_convert_breaks String, currently ignored [MT-API] .mt_text_more String, currently ignored [MT-API] .mt_excerpt String, currently ignored [MT-API] .mt_keywords String, currently ignored [MT-API] .mt_tb_ping_urls String, currently ignored [MT-API] .mt_text_more String, currently ignored [MT-API]
  • Parameter publish:
    int, 0=no, 1=yes
  • Returns
    String representing the ID of the new Story
Sourcecode in MetaWeblogApi/metaWeblogAPI.js:
1:   function newPost(blogid, username, password, content, publish) {
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:      try {
7:         blog.stories.checkAdd(usr, blog.members.getMembershipLevel(usr));
8:      } catch (deny) {
9:         throw("You don't have permission to post to this site");
10:     }
11:     var param = new Object();
12:     param.http_remotehost = "metaweblogAPI";
13:     param.content_title = content.title;
14:     param.content_text  = content.description;
15:     if (content.dateCreated)
16:       param.createtime = content.dateCreated.format("yyyy-MM-dd HH:mm");
17:     if (content.categories && content.categories.length>0)
18:        param.topic = content.categories[0];
19:     param.publish = publish;
20:     param.addToFront = (content.flNotOnHomePage && param.topic) ? false : true;
21:     param.discussions = content.discussions == 0 ? 0 : 1;
22:     try {
23:        var result = blog.stories.evalNewStory(param, usr);
24:        return result.id;
25:     } catch (e) {
26:        throw(e.toString());
27:     }
28:  }