deimantas1
New member
- Joined
- Jun 2, 2013
- Messages
- 4
Hello, I'm get problem with login to Directadmin API.
Error:
Array
(
[error] => 1
[error_msg] => CONNECTION ERROR 35: Unknown SSL protocol error in connection to deimis.zjb.lt:2222
)
Code:
I want create email account automatized with Directadmin API.
Error:
Array
(
[error] => 1
[error_msg] => CONNECTION ERROR 35: Unknown SSL protocol error in connection to deimis.zjb.lt:2222
)
Code:
Code:
<?php
include 'httpsocket.php';
$sock = new HTTPSocket;
$sock->connect('deimis.zjb.lt',2222);
$sock->set_login('login','password');
$request = "/CMD_API_POP";
$method = "POST";
$post_content = "action=create&domain=deimis.zjb.lt&user=deimiss&passwd=dFawIj"a=500";
$host = 'deimis.zjb.lt';
$port = 2222;
$retval = DA_SSL_Request("login", "password", $request, $method, $post_content, $host, $port);
echo "<pre>";
print_r($retval);
echo "</pre>";
$sock->query('/CMD_API_POP',
array(
'action' => 'create',
'add' => 'Submit',
'domain' => 'deimis.zjb.lt',
'user' => 'Testas',
'passwd' => 'testas',
'passwd2' => 'testas',
'quota' => '500'
));
$result = $sock->fetch_parsed_body();
echo $result['error'];
echo $result['text'];
function DA_SSL_Request($user, $password, $request, $method='GET', $post_content='', $host='localhost', $port=2222)
{
$headers = '';
$headers[] = "Content-Type: application/x-www-form-urlencoded";
$headers[] = 'Content-length: '.strlen($post_content);
$headers[] = 'Authorization: Basic '.base64_encode("$user:$password");
$ch = curl_init();
$complete_url = 'https://'.$host.':'.$port;
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method.' '.$request.' HTTP/1.1');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL,$complete_url);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15); // Time out sec.
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_content);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
$answer = curl_exec($ch);
if( !$answer )
{
$answer['error'] = 1;
$answer['error_msg'] = "CONNECTION ERROR ".curl_errno($ch).": ".curl_error($ch);
}
else
{
parse_str($answer,$answer);
}
return $answer;
}
?>
I want create email account automatized with Directadmin API.
Last edited by a moderator: