The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

ftp accounts setup[XML API]

Discussion in 'cPanel Developers' started by Demiurg, Jan 6, 2012.

  1. Demiurg

    Demiurg Member

    Joined:
    Jan 6, 2012
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Reseller Owner
    Hello, I've tried today serveral time to make a custom php script to create a ftp user but no result..
    The XML Api has a documentation?
    Or can you write me a fast ftp creator because I can't understand how it works..
    I run a cPanel Reseller package (cPanel Version 11.30.5 (build 3)).
    I've tried creatacct example but is not working for me.
    I'm very confused... this code creates ftp accounts?
    Code:
    include_once "../xmlapi.php" ;
    
    $ip = getenv('REMOTE_HOST');
    $root_pass = getenv('REMOTE_PASSWORD');
    
    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth("root",$root_pass);
    
    $xmlapi->set_debug(1);
    
    $acct = array( username => "someuser", password => "pass123", domain => "thisdomain.com");
    print $xmlapi->createacct($acct);
    
    Also can show me how to set up the quota?
    Please help me if you know how to create a ftp account.
    Thanx and best regards,
    Andy.
     
  2. Demiurg

    Demiurg Member

    Joined:
    Jan 6, 2012
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Reseller Owner
    Sorry for double post... If you can help me please do it, is very urgent.. I need a way to create ftp account via phphp script with the folder path in mine domain.. like domain.com/user1 another account domain.com/user2.
    No matter the method, I must do this via PHP Method.. I want to offer ftp storage to my users.
    Thank you vey much.
     
  3. Brian

    Brian Well-Known Member

    Joined:
    Dec 1, 2010
    Messages:
    117
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Texas
    cPanel Access Level:
    Root Administrator
    The createacct() PHP XMLAPI function is going to create a brand new unique cPanel user account. From what you're saying, this is not what you want to do. You want to create an FTP account. Is there any reason you're trying to create a cPanel account instead? Maybe I don't understand what you're trying to do.

    Please refer to our XML-API / API2 documentation for a list of functions you can perform.

    API2
    http://docs.cpanel.net/twiki/bin/view/ApiDocs/Api2/

    API2 through XMLAPI
    http://docs.cpanel.net/twiki/bin/view/SoftwareDevelopmentKit/CallingAPIFunctions

    Specifically, this would be the one you're interested in:

    Ftp::addftp
    http://docs.cpanel.net/twiki/bin/view/ApiDocs/Api2/ApiFtp#Ftp::addftp

    I see you're using our PHP XMLAPI Class, so just adapt that (see PHP XMLAPI's documentation) to make an API2 call to Ftp::addftp

    In fact, here's an example on how to call API2 functions from PHP XMLAPI right here:
    https://github.com/CpanelInc/xmlapi-php/blob/master/Examples/api2_example.php
    (Note that this example is also included in the PHP XMLAPI tarball that you downloaded to obtain xmlapi.php)
     
  4. Demiurg

    Demiurg Member

    Joined:
    Jan 6, 2012
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Reseller Owner
    Oh, i've readed but I can't get anything..
    So i'm able to create a ftp account with a custom phpscript with cPanel ?
    Please can you write me a little script with initialise of connection and creating a ftp account?
    I've tried many but no one works :(
    Hope you can help me..
    Thank you very much!
     
  5. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    You could take the script at:

    https://github.com/CpanelInc/xmlapi-php/blob/master/Examples/api2_example_withargs.php

    And replace the functionality to grab the disk consumption of email accounts with the API2 call to create a FTP account per the documentation at:

    ApiFtp < ApiDocs/Api2 < TWiki
     
  6. Demiurg

    Demiurg Member

    Joined:
    Jan 6, 2012
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Reseller Owner
    I've noticed that the script connects to port 2087 not 2082...
    On the port 2087 is another cpanel instance of the main hosting company, I have only a reseller...
    I get this:
     
  7. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    That error states you are connecting via a SSL protocol. Port 2082 does not support SSL. For SSL, use Port 2083 (for cPanel) or Port 2087 (for WHM).
     
Loading...

Share This Page