[Newbie] Remote API Scripts For ISPConfig 3

Discussion in 'Installation/Configuration' started by hichichachac, May 19, 2015.

  1. hichichachac

    hichichachac New Member

    Hello all,
    I'm new user and have a question about Remote API Scripts For ISPConfig 3.
    I followed link https://www.howtoforge.com/how-to-create-remote-api-scripts-for-ispconfig-3 and i don't understand location that i put new script for it possible work: it may be new file php or in file exist as remote.inc.php, config.inc.php,....
    In other word, i don't know how to use it.
    Can someone help me, please? Very thanks if guidline step by step about it.
    P/S: sorry about my English language.
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    you put the script into a webspace with php support, this can be on any server that is connected to the internet as the api works over tcp/ip.
     
    hichichachac likes this.
  3. hichichachac

    hichichachac New Member

    Hi Till, thanks for quick reply.
    I'm newbie about ispconfig and php, so can you give me a example simple for it? As you said above, example put lines in script to a file php exist as remote.ini.php, config.inc.php,...
    Follow link https://www.howtoforge.com/how-to-create-remote-api-scripts-for-ispconfig-3, i don't understand section "Using everything we have learned so far we can create" and section "Here is the beginning of the script to log into Soap" that lines code will be added where?
    Thank you.
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    I'am sorry, I cant teach you how to program php, thats a wide field. Some PHP knowledge is required to use the api, so you should consider to learn php first or ask someone with php knowledge to write the scripts for you.
     
    hichichachac likes this.
  5. hichichachac

    hichichachac New Member

    Hi Till, I'm thinking you're a little bit misleading:D I will be more specific so that you can understand and help me, please.
    When i open folder /ispconfig3_install/remoting_client/examples in the installer after unpacking, i see mutiple php file. I noticed the other php files require to file soap_config.php, but after install ispconfig 3 i don't see this file, why?
    I ask this question because follow link https://www.howtoforge.com/how-to-create-remote-api-scripts-for-ispconfig-3, as far as i understand i can write script into a file similar file soap_config.php?
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    This folder contains example scripts for you to open them on the desktop with an editor to see how a api implementation can look like. Thats nothing to be installed on a ispconfig server directly, they exist as developer reference.

    Yes. This tutorial requires that you have experience in php programming.
     
    hichichachac likes this.
  7. hichichachac

    hichichachac New Member

    Hi Till, can you tell me which folders can I put the script that I wrote like the scripts in directory /ispconfig3_install/remoting_client/examples in the installer?
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    This can be any folder on a desktop computer or server that is able to reach the server that has ispconfig installed over a tcp/ip network. The only prerequisite is that this computer has php installed (commandline php, when you write a cli script) or php in a website (apache, iis, nginx or other webserver) that has php enabled.
     
  9. hichichachac

    hichichachac New Member

    firstly let me apologize if my question somewhat naive :(
    I'm asking this book scripts on the server was installed ISPConfig:
    I find $soap_location = 'http://localhost:8080/remote/index.php' and $soap_uri = 'http://localhost:8080/remote/' are links that we can access after write scripts, content of index.php require to config.inc.php and app.inc.php,.... Then with link log into Soap, we must have some way to indicate the use of these scripts?Like that into folder /ispconfig3_install/remoting_client/examples in the installer, I noticed the other php files require to file soap_config.php
     
  10. till

    till Super Moderator Staff Member ISPConfig Developer

    When you run a remote api script on the same server where the ispconfig instance is installed that you like to connect to, then you use localhost. When you run the script on another server or your desktop, then you use the ip address or server hostname of the ispconfig server instead of localhost inside the connection string.
     
    hichichachac likes this.
  11. hichichachac

    hichichachac New Member

    Things you say I completely understand, I realized that I was misunderstood about SOAP:(

    Ok Till, but after install ispconfig 3 follow link https://www.howtoforge.com/perfect-...2-php-mysql-pureftpd-bind-dovecot-ispconfig-3, i acccess url https://ip-address:8080/remote/ and it's blank page, I also have to configure anything else?
     
  12. till

    till Super Moderator Staff Member ISPConfig Developer

    hichichachac likes this.
  13. hichichachac

    hichichachac New Member

    Thank you very much Till, I will try to practice with a simple example to understand and will discuss further with your back
     
  14. hichichachac

    hichichachac New Member

    Last edited: May 22, 2015
  15. till

    till Super Moderator Staff Member ISPConfig Developer

    The above examples and soap api is for ispconfig 3, not ispconfig 2. ISPConfig 2 and ispconfig 3 are completely different software packages, so nothing from ispconfig 3 applies to the older ispconfig 2 version. ISPConfig 2 has been discontinued years ago.
     
    hichichachac likes this.
  16. hichichachac

    hichichachac New Member

    I'm so sory because the post above is wrong information (i have changed it), exactly I'm using ispconfig 3 not 2:(
    Can you give me advice, Till?
     
  17. till

    till Super Moderator Staff Member ISPConfig Developer

  18. hichichachac

    hichichachac New Member

    It seems we do not understand each other:D
    This is content of script index.php that I write:
    Code:
    <?php
    
    /*
    $domain_id = $client->sites_ftp_user_add($session_id, $client_id, $params_ftp);
    */
    $params = array( 'server_id' => '1',
    'parent_domain_id' => $domain_id,
    'username' => $myusername,
    'password' => $mypassword,
    'quota_size' => '-1',
    'active' => 'y',
    'uid' => 'web'.$domain_id,
    'gid' => 'client'.$client_id,
    'dir' => '/var/www/clients/client'.$client_id.'/web'.$domain_id,
    'quota_files' => '100',
    'ul_ratio' => '-1',
    'dl_ratio' => '200',
    'ul_bandwidth' => '-1',
    'dl_bandwidth' => '100',);
    
    
    
    $username = 'xxx';
    $password = 'yyy';
    $soap_location = 'https://ip-address:8080/remote/index.php';
    $soap_uri = 'https://ip-address:8080/remote/';
    
    
    $client = new SoapClient(null, array('location' => $soap_location,
    
    'uri' => $soap_uri));
    try {
    //* Login to the remote server
    if($session_id = $client->login($username,$password)) {
    echo 'Logged into remote server
    sucessfully. The SessionID is '.$session_id.'
    ';
    
    
    //* Logout
    if($client->logout($session_id)) {
    echo "FTP Created";
    }
    
    } catch (SoapFault $e) {
    die('SOAP Error: '.$e->getMessage());
    echo "Please contact the server administator";
    }
    ?>
    User and password (XXX-YYY) i created in control panel, and ip-address is ip address of my server.
    It is wrong?
     
  19. till

    till Super Moderator Staff Member ISPConfig Developer

    This looks fine on the first glance. and which message do you get from this script in the browser and in the apache error,.log of the website where you uploaded it?
     
    hichichachac likes this.
  20. hichichachac

    hichichachac New Member

    Browser is blank page.
    In error.log of apache, it say "PHP Parse error: syntax error, unexpected 'catch' (T_CATCH) in /var/www/html/index.php on line 54", that mean is at section "} catch (SoapFault $e) {"?
     
    Last edited: May 22, 2015

Share This Page