1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

Expand API Fails: Unknown element 'tmpl_id'

Discussion in 'Plesk Expand 2.3 Troubleshooting Issues' started by eugenevdm, Oct 2, 2008.

  1. eugenevdm

    eugenevdm Silver Pleskian

    30
    68%
    Joined:
    Nov 11, 2003
    Messages:
    611
    Likes Received:
    0
    I'm trying to get the following example working on an Expand 2.3 server:

    Code:
    <?php
    function write_callback($ch, $data) {
         echo $data;
         return strlen($data);
    }
    
    function sendCommand($operator, $data, $login, $passwd, $host, $port=8442) {
         $script = "webgate.php";
         $url = "https://$host:$port/$script";
         $headers = array(
              "HTTP_AUTH_OP: $operator",
              "HTTP_AUTH_LOGIN: $login",
              "HTTP_AUTH_PASSWD: $passwd",
              "Content-Type: text/xml",
         );
    
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
         curl_setopt($ch, CURLOPT_HTTPHEADER, &$headers);
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_WRITEFUNCTION, write_callback);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
         curl_setopt($ch, CURLOPT_VERBOSE, 1);
         $result = curl_exec($ch);
         if (!$result) {
              echo "\n\n-------------------------\ncURL error number:".curl_errno($ch);
              echo "\n\ncURL error:".curl_error($ch);
         }
    
         curl_close($ch);
         return;
    }
    
    $data = <<<EOF
    <?xml version="1.0" encoding="UTF-8"?>
    <packet version="2.3.0.26">
         <add_use_template>
              <gen_setup>
                   <name>myowntest.domain.com</name>
                   <client_id>774</client_id>
                   <status>0</status>
                   <tmpl_id>16</tmpl_id>
              </gen_setup>
              <hosting>
                   <vrt_hst>
                        <ftp_login>ftplog</ftp_login>
                        <ftp_password>123123</ftp_password>
                   </vrt_hst>
              </hosting>
         </add_use_template>
    </packet> 
    EOF;
    
    
    
    $operator="exp_plesk_domain";
    $login="admin";
    $passwd="xxxxxx";
    $host="expand.myserver.net";
    $port=8442;
    
    sendCommand($operator, $data, $login, $passwd, $host, $port); 
    ?>
    
    If fails with:

    Please assist.
     
  2. gold

    gold Regular Pleskian

    25
    57%
    Joined:
    Jan 8, 2008
    Messages:
    307
    Likes Received:
    0
    The right XML packet is

    Code:
    <?xml version="1.0"?>
    <packet version="2.2.0.2">
        <add_use_template>
            <gen_setup>
                <name>test.domain.com</name>
                <client_id>91</client_id>
                <status>0</status>
            </gen_setup>
            <hosting>
                <vrt_hst>
                    <ftp_login>ftplogin</ftp_login>
                    <ftp_password>setup</ftp_password>
                    <fp_admin_login>fplogin</fp_admin_login>
                    <fp_admin_password>setup</fp_admin_password>
                </vrt_hst>
            </hosting>
            <user>
                <enabled>true</enabled>
                <password>setup</password>
                <multiply_login>true</multiply_login>
            </user>
            <tmpl_id>1</tmpl_id>
            <attach_to_template></attach_to_template>
        </add_use_template>
    </packet>
    
    You can get the true packets from the 'Action Input' section of 'Action Log > Action XXX' page.
     
Loading...