I really hope this will help some of you, as I spent ages searching the Internet tring to find something to do this, and ended up having to write my own.
This basically does exactly what the title says. It creates a new thread in a forum on your vbulletin forum.
It works for me in the latest version of vBulletin, but I'm not sure how far back it will work. But you should have your vBulletin up to date anyway.
If you notice any bugs/problems or anything I have done wrong, please correct me.
PHP Code:
<?php
/*======================================================================*\
|| #################################################################### ||
|| # Create a new thread # ||
|| # ---------------------------------------------------------------- # ||
|| # Hopefully this will help some of you people who are needing to # ||
|| # create a new thread externally using vBulletins API. Good luck! # ||
|| #################################################################### ||
\*======================================================================*/
// Include vBulletin runtime files
require_once('./global.php');
require_once('./includes/functions_databuild.php');
// Create a new datamanager for posting
$threaddm =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
// Set some variable and information
$forumid = 43; // The id of the forum we are posting to
$userid = 125500; // The user id of the person posting
$title = addslashes($_POST["title"]); // The title of the thread
$pagetext = addslashes($_POST["content"]); // The content of the thread
$allowsmilie = '1'; // Are we allowing smilies in our post
$visible = '1'; // If the post visible (ie, moderated or not)
// Parse, retrieve and process the information we need to post
$foruminfo = fetch_foruminfo($forumid);
$threadinfo = array();
$user = htmlspecialchars_uni( fetch_userinfo($userid) );
// Lets see what happens if we save the page
$threaddm->pre_save();
if(count($threaddm->errors) < 1) {
// Basically if the page will save without errors then let do it for real this time
$threadid = $threaddm->save();
unset($threaddm);
} else {
// There was errors in the practice run, so lets display them
var_dump ($threaddm->errors);
}
Warning: require(./includes/class_bootstrap.php) [function.require]: failed to open stream: No such file or directory in /home/x/public_html/d/vB/global.php on line 15
Warning: require(./includes/class_bootstrap.php) [function.require]: failed to open stream: No such file or directory in /home/x/public_html/d/vB/global.php on line 15
Fatal error: require() [function.require]: Failed opening required './includes/class_bootstrap.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/x/public_html/d/vB/global.php on line 15
Any ideas?
Thansk in advance
Kesandal
Edit
I could fix the problem.
For thoose who are getting the same problem;
Just add thoose few lines above your page:
is addslashes() for title & content necessary? I'm just curious if it's redundant. When I use the above, in my posts I get slashes along with my quotes