Skip to content
PHP Logo

What is the process for automatically generating forum posts in phpBB from a website?

To automatically generate forum posts in phpBB from a website, you can use the phpBB API to programmatically create new topics and posts. You will need to authenticate with the phpBB system and then use the provided functions to create the posts with the desired content.

php
define('IN_PHPBB', true);
$phpbb_root_path = './forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

$user->session_begin();
$auth->acl($user->data);
$user->setup();

// Create a new topic
$forum_id = 2; // ID of the forum where you want to create the topic
$topic_data = array(
    'forum_id'        => $forum_id,
    'topic_title'     => 'New Topic Title',
    'topic_time'      => time(),
    'topic_poster'    => $user->data['user_id'],
    'topic_first_post_subject' => 'First Post Subject',
    'topic_first_post_text'    => 'First Post Content',
    'topic_type'      => POST_NORMAL,
    'enable_bbcode'   => true,
    'enable_smilies'  => true,
    'enable_urls'     => true,
);
$topic_id = submit_post('post', $topic_data);

// Create a new post in the topic
$post_data = array(
    'topic_id'      => $topic_id,
    'forum_id'      => $forum_id,
    'post_subject'  => 'Reply Subject',
    'post_text'     => 'Reply Content',
    'poster_id'     => $user->data['user_id'],
    'post_time'     => time(),
    'enable_bbcode' => true,
    'enable_smilies'=> true,
    'enable_urls'   => true,
);
$post_id = submit_post('reply', $post_data);