Announcement

Collapse
No announcement yet.

Using API to create a user from a remote location.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • pmbs
    replied
    I know this question is quite dated but it still comes up as number 1 in google when searched for register_in_vb. I'd like to point out that you can do the following and not change the system base code (which has a comment stating not to use DIR).

    What i did was the following and it worked fine.
    Code:
    $curdir = getcwd();
    chdir('/path/to/your/forums');
    require_once('./includes/init.php');
    require_once('./includes/functions_misc.php');
    chdir($curdir);
    Last edited by pmbs; Fri 23 Jan '15, 6:47am.

    Leave a comment:


  • Quijar Haderak
    commented on 's reply
    Yes Joe, It work, thank!

  • Joe D.
    replied
    Please let me know if it works for you or not... There is some debate over whether it will work.

    Leave a comment:


  • zny_pan
    replied
    Thanks!

    Leave a comment:


  • Joe D.
    replied
    On line 39 of the file functions.php inside /includes/edit it from:

    Code:
    require_once('./includes/functions_navigation.php');
    to

    Code:
    require_once(DIR . '/includes/functions_navigation.php');
    http://tracker.vbulletin.com/browse/VBIV-15693

    Last edited by Joe D.; Sat 27 Apr '13, 3:45am.

    Leave a comment:


  • zny_pan
    replied
    Hello. Adbox's solution had been working until VB 4.2.0 PL3.
    After updating to VB 4.2.1
    I get this:
    Warning: require_once(./includes/functions_navigation.php) [[URL="http://www.xxxxx.org/function.require-once"]function.require-once[/URL="http://www.xxxxx.org/function.require-once"]]: failed to open stream: No such file or directory in [path]/includes/functions.php on line 39

    Fatal error: require_once() [[URL="http://www.xxxxx.org/function.require"]function.require[/URL="http://www.xxxxx.org/function.require"]]: Failed opening required './includes/functions_navigation.php' (include_path='.:/usr/lib/php:/usr/local/lib/php:/home/xxxxx/public_html/xxxxxx:/home/xxxxx/php') in /home/xxxx/public_html/xxxxx/includes/functions.php on line 39

    Any ideas?

    Leave a comment:


  • adbox
    replied
    I went with a custom API and had success:

    add_user.php (custom API)

    PHP Code:
    <?php

    function register_in_vb($username$password$email)
    {
        
    define('VB_AREA''External');
        
    define('SKIP_SESSIONCREATE'0);
        
    define('SKIP_USERINFO'1);
        
    define('CWD''./../../forum/' );
        require_once(
    CWD '/includes/init.php');
        require_once(
    CWD '/includes/functions_misc.php');

        
    $registry $vbulletin
        unset(
    $vbulletin); 
        
    $vbDb $registry->db
        
    //declare as global vbulletin's registry and db objects 
        
    global $vbulletin,$db
        
    $vbulletin $registry
        
    //backup the original $db object (new!!) 
        
    $backupdb $db
        
    $db $vbDb

        
    $newuser =& datamanager_init('User'$vbulletinERRTYPE_ARRAY);
        
    $newuser->set('username'$username);
        
    $newuser->set('email'$email);
        
    $newuser->set('password'$password);
        
    $newuser->set('usergroupid'9);
        
        
    $newuser->pre_save();
        
        if(empty(
    $newuser->errors)){
            
    $db $backupdb;
            echo 
    1;
            return 
    $newuser->save();
            
        }else{
            
    $db $backupdb;
            echo 
    0;
            
    print_r$newuser->errors);
        }
            
    }

    $key $_GET['key'];
    $username $_GET['username'];
    $password $_GET['password'];
    $email $_GET['email'];

    if (
    $key=='mysecretkey')
    {
        
    // Add the users to vBulletin
        
    $newuserid register_in_vb($username$password$email);
    }

    ?>

    Leave a comment:


  • punchbowl
    replied
    yep: http://www.vbulletin.com/forum/conte...elated-Methods

    Leave a comment:


  • adbox
    started a topic [Forum] Using API to create a user from a remote location.

    Using API to create a user from a remote location.

    Hello VB support,

    I need to develop or find a php script that will allow(aid) me to add a user to my remote forum using the vbulletin API. I have generated the API key, but I just do not know the URL to post to and the parameters to include in the URL in order to add the user.

    I'm assuming that the api can do this, can it?

    Alternatively I can create my own API with a php script hosted on the remote server, which can intercept and add the user because it has included the vbulletin files that will allow it to use it's functions, but I need help with this too because I'm hoping not to spend more than a day on the project...

    Hopefully someone here has something cooked up.

    Thanks for the attention!
    Hudson

Related Topics

Collapse

Working...
X