1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

forumConnector

Discussion in 'Add-on Releases [Archive]' started by Benjy, Nov 18, 2010.

Thread Status:
Not open for further replies.
  1. Benjy

    Benjy Well-Known Member

    THIS IS NO LONGER SUPPORTED, PLEASE USE THIS INSTEAD!

    Description
    This script allows you to access (some of) your xF data remotely and retrieve it in XML. This is very useful if you don't want to include a load of scripts/frameworks in your website, yet want to connect it to your forums (e.g. a news system which comments come from a forum or simply a login box).

    Limitations
    - For the isloggedin function, your website must have access to your forum cookies.
    - Facebook Connect automatic connection isn't handled (that is, if a FB session exists and a xF doesn't, the xF session won't be created).

    How to use it
    - Place the Server script at the root of your xF installation (and rename it to whatever you want, for security purposes)
    - Place the Client script where you include your libs on your website, require it then:
    PHP:
    /* Example usage */
    $fcc = new forumConnect_Client('xenForo''http://www.example.org/forums''_myconnector.php');
    $isloggedinxml $fcc->isloggedin('xf_');
    $threadxml $fcc->getthread(1);
    Methods
    Name: isloggedin
    Parameters: sessionid (string, e.g. $_COOKIE['xf_session']), ipaddress (string, e.g. $_SERVER['REMOTE_ADDR']), sessionuser (string, e.g. $_COOKIE['xf_user'])​
    Returns on success:
    Code:
    <user>
    <userid>int</userid>
    </user>
    Returns on failure:
    Code:
    <user>
    <userid>0</userid>
    </user>

    Name: getthread
    Parameters: threadid(int), getposts(bool)​
    Returns on success:
    Code:
    <thread>
    <threadid>int</threadid>
    <description>string</description>
    <title>string</title>
    <url>string</url>
    <firstpostid>int</firstpostid>
    <lastpostid>int</lastpostid>
    <forumid>int</forumid>
    <replycount>int</replycount>
    <lastusername>string</lastusername>
    <lastuserid>int</lastuserid>
    <dateline>int</dateline>
    <views>int</views>
    <votecount>int</votecount><!-- not ([URL='http://xenforo.com/community/threads/thread-rating-system-reputation-system.6357/']yet[/URL]?) supported -->
    <votetotal>int</votetotal><!-- not ([URL='http://xenforo.com/community/threads/thread-rating-system-reputation-system.6357/']yet[/URL]?) supported -->
    <isdeleted>bool</isdeleted>
    <isopen>bool</isopen>
    <issticky>bool</issticky>
    <isvisible>bool</isvisible>
    <!-- if getposts is TRUE -->
    <posts>
    <post>
    <postid>int</postid>
    <parentid>int</parentid>
    <title>string</title>
    <dateline>int</dateline>
    <content>string</content>
    <url>string</url>
    <isdeleted>bool</isdeleted>
    <isvisible>bool</isvisible>
    <user>
    <userid>int</userid>
    <usergroupids>string</usergroupids>
    <username>string</username>
    <usertitle>string</usertitle>
    <email>string</email>
    <avatarurl>string</avatarurl>
    <logouthash>string</logouthash>
    <isadmin>bool</isadmin>
    <isbanned>bool</isbanned>
    <isvalid>bool</isvalid>
    </user>
    </post>
    </posts>
    <!-- elseif getposts is FALSE -->
    <user>
    <userid>int</userid>
    <usergroupids>string</usergroupids>
    <username>string</username>
    <usertitle>string</usertitle>
    <email>string</email>
    <avatarurl>string</avatarurl>
    <logouthash>string</logouthash>
    <isadmin>bool</isadmin>
    <isbanned>bool</isbanned>
    <isvalid>bool</isvalid>
    </user>
    </thread>
    Returns on failure:
    Code:
    <thread>
    <threadid>0</threadid>
    </thread>

    Name: getuser
    Parameters: userid (int)​
    Returns on success:
    Code:
    <user>
    <userid>int</userid>
    <usergroupids>string</usergroupids>
    <username>string</username>
    <usertitle>string</usertitle>
    <email>string</email>
    <avatarurl>string</avatarurl>
    <logouthash>string</logouthash>
    <isadmin>bool</isadmin>
    <isbanned>bool</isbanned>
    <isvalid>bool</isvalid>
    </user>
    Returns on failure:
    Code:
    <user>
    <userid>0</userid>
    </user>
    Where can I find it?
    Here: http://code.google.com/p/forumconnect/
    And more specifically:
    Future
    - ?

    FAQ
    - Is this bug free? No.
    - Why is your OO code awful? I don't like OO much but I wanted to sandbox this a maximum.
    - Are you looking for help? Of course! My goal was to start this, then let the community enhance it.
    - What about the vB... script I see in the repository? Wouldn't it be great if it could handle multiple forum softwares? :)
     
  2. Weiyan

    Weiyan Well-Known Member

    Its sounds good and seems helpful for admin for multiple sites. I will not use it now until there are more simple user interface for I am poor at programing.
     
  3. Floris

    Floris Guest

    Thanks for making and sharing
     
  4. Benjy

    Benjy Well-Known Member

    Just added the getthread method.

    NB: inserting URL tags inside CODE tags doesn't seem to work. Is it intended?
     
  5. ragtek

    ragtek Guest

    You should use call_user_func instead of
    PHP:
     eval('$this->_' $function '();');
    ;)
     
  6. Benjy

    Benjy Well-Known Member

    Done, thanks! (as least I know someone is reading the code :p)
     
  7. ragtek

    ragtek Guest

    Yea;)

    I'M having something similar for my vB boards, and i started some time ago to work on a xenforo version, but then i saw that you have it already for xenforo:)

    Other suggestion:
    returnStats => return threadcounter, postcounter, usercounter
    returnNewestUser


    Then, if you want to have a REAL NICE,CLEAR and extendable(for add-ons) Interface, you could move the methods into own files.
    This would make it easier to add own methods (for example for add-ons)
    My interface looks like:

    class ragtek_api (provides the necessery methods and calls the other files)
    abstract class ragtek_apiCall
    class ragtek_API_Linklist extends ragtek_apiCall => includes methods to return elements from my linklist
    class ragtek_API_User => includes methods for user actions => createUser, getUserInfo, getNewestUser, getNewestUsers
    class ragtek_API_Thread => includes methods for thread actions => getThread, createThread,
    class ragtek_API_Post => includes Methods for post actions => getPost, createPost,
    .....


    Sorry for my bad englisch, hope you know what i mean^^
     
  8. Benjy

    Benjy Well-Known Member

    I put everything in a single file because I didn't want to mess too much with the file structure. Also, the website and the forum can be on different servers or on the same server but under different *NIX users so I will make a client (which has to be the same whatever the forum is) which will do cURL calls to that single file.
    That being said, the single file could also be a single folder ;) In which case I can have multiple files for all the method groups.

    Also, keep in mind that I did this more as a proof-of-concept. Anybody is welcome to enhance it and I will gladly share my SVN access.

    Also: createthread is planned.
     
  9. ragtek

    ragtek Guest

    I'm talking about the server and not client.

    Client calls => URL/script?do=Forum_getNewestThread&f=1
    Server runs method "getNewestThread" from api class forum and returns the values.

    You know what i mean?:)

    And for the create actions, i would implemt an "API Key" and allow only post data.
    client call (pseudo code):
    PHP:
        $http = new Zend_Http_Client();

        
    $http->setUri('http://api.ragtek.org/v2');
        
    $http->setParameterPost('apikey'RAGTEK_APIKEY);  
          
        
    $postData 'do=createThread&content=' urlencode($_GET['content'] . '&f=' $_GET['fid']);
      
        
        
    $httpResponse $http->post($postData);
        

    also i found a little error in your code:
    PHP:
           /**
             * _isloggedin - check if user is logged in
             * NB: ipaddress comes from $_SERVER, the other variables come from the user's cookie.
             * 
             * @return void
             */
            
    protected function _isloggedin()
            {
                    
    $controller = new XenForo_Controller_forumConnect($this->_request$this->_response, new XenForo_RouteMatch());
                    
    $controller->preDispatch('');
                    
                    
    $visitor XenForo_Visitor::getInstance();
                    
                    
    $usernode $this->xml->createElement('user');
                            
    $usernode->appendChild($this->xml->createElement('userid'$visitor->getUserId()));

                    
    $this->xml->appendChild($usernode);
                    
                    echo 
    $this->xml->saveXML();
                    exit;
            }
    [/
    pph]
    It returns the userid and not true/false as you "commented"
     
  10. Benjy

    Benjy Well-Known Member

    I did understand :)

    Also, I first wanted to make an oAuth application but this is 99% intended to be used for 1 forum to 1 website communication so it's a bit too far reached. That's also why my suggestion for the security problem was to rename the script :p (as in the client you will have to tell the script's name)

    ?? (see first post, I wrote that it returns an int on success and 0 on failure as the userid).
     
  11. Benjy

    Benjy Well-Known Member

    Just posted a quick client and corrected a bug with xenForo not liking POSTs without tokens.
     
  12. ragtek

    ragtek Guest

    One more suggestion:

    PHP:
            public function call($function)
            {
                    if (
    in_array($function, array(
                            
    'getthread',
                            
    'getuser',
                            
    'isloggedin'
                    
    )))
                    {
                            
    call_user_func(array($this'_' $function));
                    }

    I would change this to
    PHP:
    protected $allowedCalls = array(
    'getthread',
                            
    'getuser',
                            
    'isloggedin');

            public function 
    call($function)
            {
                    if (
    in_array($function$this->allowedCalls
                    
    ))
                    {
                            
    call_user_func(array($this'_' $function));
                    }
    HMM, maybe you could give me svn access?*g*
     
  13. Benjy

    Benjy Well-Known Member

    Send me your gmail via PM :)
     
    ragtek likes this.
  14. ragtek

    ragtek Guest

    Little Update:

    I'm working on a new version of this great add-on.

    The new architecture will allow 3rd party developers, to add there own methods/calls to the connector system.
     
    Benjy likes this.
  15. Benjy

    Benjy Well-Known Member

    Added isadmin flag to user info.
     
  16. kkm323

    kkm323 Well-Known Member

    I am sorry!! am I missing something here. because, I don't understand what this mod does to your forum.
     
  17. Benjy

    Benjy Well-Known Member

    It allows you to access your forum data through your website. It doesn't modify your forum in any way.
     
  18. kingston

    kingston Well-Known Member

    Posts and users/passwords?
     
  19. Benjy

    Benjy Well-Known Member

    Check if a user is logged in, retrieve user info and thread info.
     
  20. Digital Doctor

    Digital Doctor Well-Known Member

    Anyone using this ? Is maison.com still using it ?
     
Thread Status:
Not open for further replies.

Share This Page