foreach ($res['ResourceRecordTemplate']['InfoTypes']['@attributes'] as $infoName => $value) { $infoTypesRequired[str_replace('Type', 'Value', $infoName)] = $value; } } // Now match against what options were passed $infoTypesSupplied = UltraDNS::parseInfoFlags(6); $missing = array_diff_key($infoTypesRequired, $infoTypesSupplied); if (sizeof($missing)) { $resp = "\n[36mSample Usage:[0m {$argv[0]} [31m{$argv[1]}[0m [32m[zoneName][0m [32m[rrType][0m " . "[32m[dName][0m [32m[ttl][0m"; foreach ($infoTypesRequired as $k => $v) { $resp .= " [32m" . str_replace('Type', 'Value', $k) . ":[" . $v . "][0m"; } echo $resp . "\n"; die("\n"); } else { foreach ($infoTypesSupplied as $k => $v) { $call_params[$k] = $v; } } UltraDNS::doRequest($argv[1], $call_params); } } elseif ($argv[1] == 'help' || $argv[1] == '' || !isset($argv[1])) { echo "\nAvailable commands: \n\n"; $commands = UltraDNS::getAvailableCommands(); sort($commands); foreach ($commands as $cmd) { echo "\t[31m{$cmd}[0m\n"; } echo "\n[36mSample Usage:[0m {$argv[0]} [31m[queryType][0m [32m[param1][0m [32m[param2][0m ...\n\n"; } echo "\n";
public static function doRequest($type, $params = array(), $as_return = false) { if (self::$test_mode) { self::$url = 'http://testapi.ultradns.com/UltraDNS_WS/v01?wsdl'; } else { self::$url = 'http://ultra-api.ultradns.com:8008/UltraDNS_WS?wsdl'; } if ($type == 'describe') { $client = new SoapClient(self::$url, array('trace' => 1, 'cache_wsdl' => WSDL_CACHE_NONE, 'use' => SOAP_LITERAL, 'style' => SOAP_DOCUMENT)); return $client->__getFunctions(); } $xml = ' <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v01="http://webservice.api.ultra.neustar.com/v01/" xmlns:sch="http://schema.ultraservice.neustar.com/v01/"> <soapenv:Header> <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:UsernameToken wsu:Id="UsernameToken-16318950" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <wsse:Username>' . self::$user . '</wsse:Username> <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">' . self::$pass . '</wsse:Password> </wsse:UsernameToken> </wsse:Security> </soapenv:Header> <soapenv:Body> ' . self::getBodyXml($type, $params) . ' </soapenv:Body> </soapenv:Envelope> '; try { $soap_do = curl_init(); curl_setopt($soap_do, CURLOPT_URL, self::$url); curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($soap_do, CURLOPT_TIMEOUT, 10); curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true); curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($soap_do, CURLOPT_POST, true); curl_setopt($soap_do, CURLOPT_POSTFIELDS, $xml); curl_setopt($soap_do, CURLOPT_HTTPHEADER, array('Content-Type: text/xml; charset=utf-8', 'Content-Length: ' . strlen($xml))); $raw_xml = curl_exec($soap_do); $info = curl_getinfo($soap_do); $err = curl_error($soap_do); $result = str_replace(array('soap:', 'ns1:', 'ns2:'), '', $raw_xml); $result = json_decode(json_encode(simplexml_load_string($result, 'SimpleXMLElement', LIBXML_NOCDATA)), true); } catch (Exception $e) { return "ERROR: " . $e->message . "\n"; } if (UltraDNS::$debug == true) { echo "\n--------------------------\nREQUEST BODY:\n------------------------\n\n" . $xml . "\n"; echo "\n--------------------------\nRESULT HEADERS:\n------------------------\n\n" . print_r($info) . "\n"; echo "\n--------------------------\nRESPONSE BODY:\n------------------------\n\n"; print_r($raw_xml) . "\n"; echo "\n--------------------------\nRESPONSE ARRAY:\n------------------------\n\n"; print_r($result) . "\n"; } if (isset($result['Body']['Fault'])) { if (isset($result['Body']['Fault']['detail']['UltraWSException'])) { $err = $result['Body']['Fault']['detail']['UltraWSException']; echo "\n[31m ERROR " . $err['errorCode'] . "[32m: " . $err['errorDescription'] . "[0m" . CRLF; } elseif (isset($result['Body']['Fault']['faultstring'])) { $err = $result['Body']['Fault']['faultstring']; echo "\n[31m ERROR[0m : " . $result['Body']['Fault']['faultstring'] . CRLF; } } return self::getResult($type, $result['Body'][$type . 'Response'], $as_return); }