Subject: | Undocumented postid in Engine::Userland::metaWeblog.pm |
According to the Net::Blogger::Engine::Userland::metaWeblog POD docs (which ::MT uses), an editPost can be passed 'title', 'link', 'description', 'categories' and 'publish'. As such, I erroneously expected this code to work:
my $id = $mt->metaWeblog()->newPost(
title => "$item->{title}",
description => "$item->{description}",
publish => 1)
or die "[err] ", $mt->LastError(), "\n";
# "edit" the post with no changes so
# that our category change activates.
$mt->metaWeblog()->editPost(
title => "$item->{title}",
description => "$item->{description}",
publish => 1)
since they're sharing the same $mt object. That's not the case - there's an undocumented 'postid' for editPost (see your metaWeblog.pm source). The minute I pass that in, with a publish => 1, MT properly rebuilds the entry. The following does what I want (which is to create a new entry, rebuild, assign a category, rebuild):
# it is! yes! now, post to the blog.
print "Publishing item '$item->{title}'.\n";
my $id = $mt->metaWeblog()->newPost(
title => "$item->{title}",
description => "$item->{description}",
publish => 1)
or die "[err] ", $mt->LastError(), "\n";
# set the category?
if ($opts{catid}) {
$mt->mt()->setPostCategories(
postid => $id,
categories => [ {categoryId => $opts{catid}}])
or die "[err] ", $mt->LastError(), "\n";
# "edit" the post with no changes so
# that our category change activates.
$mt->metaWeblog()->editPost(
title => "$item->{title}",
description => "$item->{description}",
postid => $id,
publish => 1)
}