Currently you'd need to script the whole thing, pretty much duplicating a good portion of the addpost.inc.php script. With version 8.0 that we're working on now there will be an API available that will make this much easier.