PDA

View Full Version : Adding Post to thread via API


vrinteractive
12-02-2010, 04:44 PM
I've integrated a function of our website with vbulletin via the API to create a post in a thread on our forum.

I've got this working with ONE problem: the thread statistics aren't being updated!

The post is added to the thread. The post is visible in the thread. However, on the forum page that lists the thread, the "Last Post" column is not updated correctly. The "Replies" column is not updated either.

Here's the code I'm using. What am I missing?


<?
require_once('./global.php');
require_once('./includes/class_dm.php');
require_once('./includes/class_dm_threadpost.php');

$postdm = new vB_DataManager_Post($vbulletin, ERRTYPE_STANDARD);

$postthreadid = $_REQUEST['threadid'];
$postuserid = $_REQUEST['postuserid'];
$postpagetext = $_REQUEST['postbody'];

$postdm->set('threadid', $postthreadid);
$postdm->set('userid', $postuserid);
$postdm->set('pagetext', $postpagetext);
$postdm->set('allowsmilie', 1);
$postdm->set('visible', 1);
$postdm->set('dateline', TIMENOW);
$postdm->save();
unset($postdm);
?>


--------------- Added 1291344018 at 1291344018 ---------------

FYI - If anyone else runs into this. Seems I missed a few lines of code:


$threadinfo = fetch_threadinfo($postthreadid);
$foruminfo = fetch_foruminfo($threadinfo['forumid']);

$postdm->set_info('forum', $foruminfo);
$postdm->set_info('thread', $threadinfo);