MetaWeblogApi.editPost (postid, username, password, content, publish)
metaWeblog.editPost updates information about an existing post

  • Parameter postid:
    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
    Boolean true if successful
Sourcecode in MetaWeblogApi/metaWeblogAPI.js:
1:   function editPost(postid, username, password, content, publish) {
2:      var usr = root.blogger.getUser(username, password);
3:      var entry = root.storiesByID.get(postid.toString());
4:      if (!entry)
5:         throw("Couldn't find the story with id " + postid);
6:      // check if user is allowed to edit the story
7:      try {
8:         entry.checkEdit(usr, entry.site.members.getMembershipLevel(usr));
9:      } catch (deny) {
10:        throw("You're not allowed to edit the story with id " + postid);
11:     }
12:     var param = new Object();
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.mt_allow_comments == 0 ? 0 : 1;
22:     try {
23:        entry.evalStory(param, usr);
24:        return true;
25:     } catch (e) {
26:        throw(e.toString());
27:     }
28:  }