尝试使用 PHP 和 AWS Route53 发出 API 请求
Trying to make an API request using PHP with AWS Route53
我需要向 AWS Route53 发出一个 API 请求以创建可重用委托集。您不能通过控制台 Web 界面执行此操作,它必须通过 API.
这里是发出这个 API 请求的文档:http://docs.aws.amazon.com/Route53/latest/APIReference/api-create-reusable-delegation-set.html
<?php
$baseurl = "route53.amazonaws.com/2013-04-01/delegationset";
$body = '<?xml version="1.0" encoding="UTF-8"?>
<CreateReusableDelegationSetRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
<CallerReference>whitelabel DNS</CallerReference>
</CreateReusableDelegationSetRequest>';
$ch = curl_init();
// Set query data here with the URL
curl_setopt($ch, CURLOPT_URL, $baseurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, $body );
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: route53.amazonaws.com','X-Amzn-Authorization: '));
curl_setopt($ch, CURLOPT_TIMEOUT, '3');
$rest = curl_exec($ch);
if ($rest === false)
{
// throw new Exception('Curl error: ' . curl_error($crl));
print_r('Curl error: ' . curl_error($ch));
}
curl_close($ch);
print_r($rest);
?>
我知道请求不是 signed/authenticated,但我什至无法连接到服务器。我至少希望在继续之前收到一条错误消息,说明我未通过身份验证。相反,我得到的只是 "connection refused".
我确定我在这里做的事情完全错误。但是Google一直没有用。
scrowler 是对的。我改变了:
$baseurl = "route53.amazonaws.com/2013-04-01/delegationset";
到
$baseurl = "https://route53.amazonaws.com/2013-04-01/delegationset";
我收到了预期的错误消息,现在我可以继续下一步了。
我需要向 AWS Route53 发出一个 API 请求以创建可重用委托集。您不能通过控制台 Web 界面执行此操作,它必须通过 API.
这里是发出这个 API 请求的文档:http://docs.aws.amazon.com/Route53/latest/APIReference/api-create-reusable-delegation-set.html
<?php
$baseurl = "route53.amazonaws.com/2013-04-01/delegationset";
$body = '<?xml version="1.0" encoding="UTF-8"?>
<CreateReusableDelegationSetRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
<CallerReference>whitelabel DNS</CallerReference>
</CreateReusableDelegationSetRequest>';
$ch = curl_init();
// Set query data here with the URL
curl_setopt($ch, CURLOPT_URL, $baseurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, $body );
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: route53.amazonaws.com','X-Amzn-Authorization: '));
curl_setopt($ch, CURLOPT_TIMEOUT, '3');
$rest = curl_exec($ch);
if ($rest === false)
{
// throw new Exception('Curl error: ' . curl_error($crl));
print_r('Curl error: ' . curl_error($ch));
}
curl_close($ch);
print_r($rest);
?>
我知道请求不是 signed/authenticated,但我什至无法连接到服务器。我至少希望在继续之前收到一条错误消息,说明我未通过身份验证。相反,我得到的只是 "connection refused".
我确定我在这里做的事情完全错误。但是Google一直没有用。
scrowler 是对的。我改变了:
$baseurl = "route53.amazonaws.com/2013-04-01/delegationset";
到
$baseurl = "https://route53.amazonaws.com/2013-04-01/delegationset";
我收到了预期的错误消息,现在我可以继续下一步了。