Something like:
PHP Code:
// Path to the vBulletin 5 folder.
// '.' indicates current directory where the .htaccess file resides.
$vbpath = '.';
define('CSRF_PROTECTION', false);
require_once($vbpath . '/includes/vb5/autoloader.php');
vB5_Autoloader::register($vbpath);
vB5_Frontend_Application::init('config.php');
$api = Api_InterfaceAbstract::instance();
$row = 1;
if (($handle = fopen('yourdata.csv', 'r')) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ',')) !== FALSE) {
$num = count($rowfields);
echo '<p> ' . $num . ' fields in line ' . $row . ': <br /></p>';
$row++;
$post_title = $rowfields[0];
$post_content = $rowfields[1];
// then you call the thread creator
$thread = $api->callApi('content_text', 'add', [
'data' => [
'rawtext' => $post_content,
'title' => $post_title,
'parentid' => 3, // ID of the forum section (or node as they call it in vBulletin 5)
'userid' => 1 // ID of the user to post the thread as
],
'options' => [
'nl2br' => true
]
]);
}
fclose($handle);
}
You still need to modify the parentid and userid value.
Pretty sure the script you gave is not valid though because it calls the $rowfields variable which does not exist.