Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrected communication with DotTK registrar #13

Merged
merged 1 commit into from
Mar 24, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 38 additions & 17 deletions bb-library/Registrar/Adapter/Dottk.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ private function _rest_call($call, $args = array())
$nameservers = null;
$keywords = null;

$args['email'] = $this->config['email'];
$args['password'] = $this->config['password'];
$args['email'] = urlencode($this->config['email']);
$args['password'] = urlencode($this->config['password']);

if (array_key_exists("nameservers", $args)) {
if($args["nameservers"] != null) {
Expand Down Expand Up @@ -248,21 +248,42 @@ private function _rest_call($call, $args = array())
if ($keywords)
$postdata = $postdata."&keyword=".join("&keyword=", $keywords);

$opts=array("http" => array("method" => "POST",
"header" => "Content-type: application/x-www-form-urlencoded",
"content" => $postdata));

$res = stream_context_create($opts);
$output = file_get_contents($base_url . $call . ".json", false, $res);
$response = json_decode($output,true);

if($this->_testMode){
error_log("DotTk Response: " . print_r($response, 1));
}

if($response['status'] == 'NOT OK') {
throw new Registrar_Exception($response['reason']);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $base_url . $call . ".json");
curl_setopt($ch, CURLOPT_POST, true);
//curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// curl_setopt($ch, CURL_IPRESOLVE_V4, true);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);

// Disabling SSL Certificate support temporarly
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);

$output = curl_exec($ch);
if($output) {
$pos = strrpos($output, "<!DOCTYPE");
if($pos !== false) {
$output = substr($output,0,$pos);
}
$response = json_decode($output,true);

if($this->_testMode){
error_log("DotTk Response: " . print_r($response, 1));
}

if($response['status'] == 'NOT OK') {
throw new Registrar_Exception($response['reason']);
}
} else {
$error = curl_error($ch);
if($error) {
throw new Registrar_Exception("CURL ERROR: " . $error);
} else {
throw new Registrar_Exception("Unable to reach server.");
}
}

return $response;
}
Expand Down