1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

External post

Discussion in 'XenForo Development Discussions' started by Laric, Oct 10, 2010.

  1. Laric

    Laric Active Member

    From an external script how would I go about creating a thread with the initial post in it?

    And the post would be in a forum where I (as the user) don't have access?

    (A newly registered user will use an external script to answer a few questions and the results will be posted in the staff section of my forum)
  2. Shadab

    Shadab Well-Known Member

    Take a look at how it's done in: /library/XenForo/ControllerPublic/Forum.php

    This method, in particular:
  3. ragtek

    ragtek Guest

    You can use the datawriter for this;)

    I've created an Helper Class for my Add-ons which helps me creating users,threads,posts, etc..

    This is my helper collectionto make coders live easier;)
     * @
    copyright ragtek
    * @version 1.0.2
    * @package ragtek/helper

         * @param XenForo_Visitor $user
         * @param <int> $forumId
         * @param <str> $subject
         * @param <str> $message
         * @return <array> Thread Information
    static public function createThread(XenForo_Visitor $user$forumId$subject$message)
    $writer XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
    $postWriter $writer->getFirstMessageDw();


    $input['subject'], $input['message']);
    YOu can see it here in action => http://xenforo.com/community/posts/88981/
  4. Laric

    Laric Active Member

    I was thinking of an entirely external script that would need to setup the xenforo classes etc as well. Not like an addon to xenforo but one that gets called on it's own. www.mydomain.com/script.php
  5. Shadab

    Shadab Well-Known Member

    Data writers, Models, etc. can be utilized outside of your conventional MVC environment as well. You just need to set up the autoloader and initialize the xf Framework from your script; to make use of xf classes.

    // Required? Not sure.

    $startTime microtime(true);
    $fileDir dirname(__FILE__);

    $fileDir '/library/XenForo/Autoloader.php');
    XenForo_Autoloader::getInstance()->setupAutoloader($fileDir '/library');

    // Cannot confirm if starting the application is required or not
    XenForo_Application::initialize($fileDir '/library'$fileDir);
  6. ragtek

    ragtek Guest

    A REST API Feature would be great:D

Share This Page