API: Topics and Posts

IPB new api to create topics.

With IPB new API there are so many more options to mod authors, with frequently used tasks being much easier to access. One important one is the API: Topics and Posts.
The below code will create my test topic, and redirect me to it automatically.
/*-------------------------------------------------------------------------*/
// Dev Fuse Example - Include and Set API
/*-------------------------------------------------------------------------*/
include_once("sources/api/api_topics_and_posts.php");
$api = new api_topics_and_posts();
$api->ipsclass = &$this->ipsclass;
$api->set_author_by_name("Michael"); /* Use the actual member name not id */
$api->set_post_content("Hello test post."); /* Post */
$api->set_forum_id("2"); /* The forum ID to post in */
$api->set_topic_title("Michaels test post"); /* The topic title */
$api->set_topic_description("Testing"); /* The topic description */
$api->set_topic_state('open'); /* The topic state 'open' or 'closes' to choose from */
$api->create_new_topic();
$this->ipsclass->print->redirect_screen("Redirecting to topic now", "showtopic={$api->topic_id}" );

Some optional settings
$api->delay_rebuild = 1; /* Choose to delay stats rebuilding */
$api->topic_id; /* Id number of the new topic */

AddThis Social Bookmark Button AddThis Feed Button