I have done something similar to this. I created an API wrapper in the frontend controller. You don't have to include any file at all.
Create a php file named apiwrapper.php in /includes/vb5/frontend/controller directory. The class name suffix has to match the filename.
PHP Code:
<?php class vB5_Frontend_Controller_ApiWrapper extends vB5_Frontend_Controller { public function __construct() { parent::__construct(); }
public function actionCreatePost() {
// validate ip address to restrict unauthorized calls
// validate input data in $_POST
// set user session to a user that has create post permission: // $this->setUserSession(1);
// call content api to create the node passing all the required parameters: // $nodeid = Api_InterfaceAbstract::instance()->callApi('content_text', 'add', array($data, array())); // $data is an array containing title, parentid, rawtext, userid, etc.
// return the nodeid generated as a JSON: // $result['nodeid'] = $nodeid; // $this->sendAsJson($result);
if ($userid != $postUserId) { $newsession = new vB_Session_Cli(vB::getDbAssertor(), vB::getDatastore(), vB::getConfig(), $postUserId); vB::setCurrentSession($newsession); }
}
}
To call actionCreatePost() method, use CURL, jQuery (if forum is on same domain as the originating call) or any tool/library that supports HTTP transfer. The URL endpoint for the call is http://yourdomain.com/apiwrapper/createPost then you have to pass the parameters as POST data.