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

Creating IDN Domain through API

Discussion in 'Plesk Expand 2.3 General Discussion' started by michael.gysin, Jul 3, 2009.

  1. michael.gysin

    michael.gysin New Pleskian

    22
    73%
    Joined:
    Oct 7, 2008
    Messages:
    17
    Likes Received:
    0
    Hi there
    I've coded a middleware between plesk expand and our own CRM system. I used the vb.net sample in the Plesk API RPC Protocol Developer's Guide. Nearly everything works perfect, but if I want to setup a IDN domain like 'röschti.ch' the Expandserver gets 'r?schti.ch' sent. The request packet is encoded as ASCII. I tried UTF8, Unicode and others but then I do not even get a response from the server.

    Has somebody an idea how to solve?

    Parameter message is the xml request packet which contains probably öäü

    Private Function SendRequest(ByVal message As String) As HttpWebRequest
    Dim request As HttpWebRequest = DirectCast(WebRequest.Create(Me.AgentEntryPoint), HttpWebRequest)
    request.Method = "POST"
    request.Headers.Add("HTTP_AUTH_OP", Me.operation)
    request.Headers.Add("HTTP_AUTH_LOGIN", Me.Login)
    request.Headers.Add("HTTP_AUTH_PASSWD", Me.Password)
    System.Net.ServicePointManager.Expect100Continue = False
    request.ContentType = "text/xml"
    request.ContentLength = message.Length
    Dim bytes As Byte() = New ASCIIEncoding().GetBytes(message)
    Using stream As Stream = request.GetRequestStream
    stream.Write(bytes, 0, message.Length)
    End Using
    Return request
    End Function

    Plesk Expand on CentOS, Version 2.3.2, Build 17

    Thanks for your help.
    Michael
     
  2. michael.gysin

    michael.gysin New Pleskian

    22
    73%
    Joined:
    Oct 7, 2008
    Messages:
    17
    Likes Received:
    0
    I figured out that german umlaute like öäü etc are generally a problem. It seems that the api only accepts ASCII encoding. Any ideas?

    Michael
     
  3. gold

    gold Regular Pleskian

    25
    57%
    Joined:
    Jan 8, 2008
    Messages:
    307
    Likes Received:
    0
    I have successfully created IDN domain using the followng command

    Code:
    exec-webgate-command -o exp_plesk_domain < add.xml
    
    exec-webgate-command
    Code:
    #!/usr/bin/sw-engine -n
    <?php
    
    $options = getopt("hl:o:p:u:");
    if ( false === $options || isset($options["h"]) || !isset($options["o"]) ) {
        $cmd = basename($_SERVER['argv'][0]);
        echo <<<USAGE
    Usage: $cmd [options]
      -h          display help and exit
      -l          login
      -o          operator
      -p          password
      -u <url>    URL to remote API (http://your.host:8442/webgate.php)
    USAGE;
        echo "\n";
        exit(0);
    }
    
    $login = isset($options["l"]) ? $options["l"] : "admin";
    $operator = $options["o"];
    $password = isset($options["p"]) ? $options["p"] : "setup";
    $url = isset($options["u"]) ? $options["u"] : "https://localhost:8442/webgate.php";
    
    $headers = array(
    	"HTTP_AUTH_OP: $operator",
    	"HTTP_AUTH_LOGIN: $login",
    	"HTTP_AUTH_PASSWD: $password",
    	"Expect:",
    	"Content-Type: text/xml",
    );
    
    $curl_handler = curl_init($url);
    curl_setopt($curl_handler, CURLOPT_POST, 1);
    curl_setopt($curl_handler, CURLOPT_VERBOSE, 0);
    curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl_handler, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curl_handler, CURLOPT_HTTPHEADER, $headers);
    
    $cmd = file_get_contents('php://stdin');
    curl_setopt($curl_handler, CURLOPT_POSTFIELDS, $cmd);
    $result = curl_exec($curl_handler);
    if ( false === $result ) {
        die("Failed to execute command: ".curl_error($curl_handler)."\n");
    }
    echo "$result\n";
    
    ?>
    
    
    add.xml
    Code:
    <?xml version="1.0"?>
    <packet version="2.3.3.13">
        <add>
            <gen_setup>
                <name>röschti3.ch</name>
                <client_id>231</client_id>
                <status>0</status>
                <use_ip>
                    <ip_address>10.10.10.10</ip_address>
                </use_ip>
            </gen_setup>
            <preferences>
                <www>true</www>
                <stat_ttl>0</stat_ttl>
            </preferences>
        </add>
    </packet>
    
     
Loading...