示例#1
0
            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 = "\nSample Usage: {$argv[0]} {$argv[1]} [zoneName] [rrType] " . "[dName] [ttl]";
            foreach ($infoTypesRequired as $k => $v) {
                $resp .= " " . str_replace('Type', 'Value', $k) . ":[" . $v . "]";
            }
            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{$cmd}\n";
    }
    echo "\nSample Usage: {$argv[0]} [queryType] [param1] [param2] ...\n\n";
}
echo "\n";
示例#2
0
    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 ERROR " . $err['errorCode'] . ": " . $err['errorDescription'] . "" . CRLF;
            } elseif (isset($result['Body']['Fault']['faultstring'])) {
                $err = $result['Body']['Fault']['faultstring'];
                echo "\n ERROR : " . $result['Body']['Fault']['faultstring'] . CRLF;
            }
        }
        return self::getResult($type, $result['Body'][$type . 'Response'], $as_return);
    }