【发布时间】:2015-04-29 03:25:27
【问题描述】:
我需要向 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);
?>
我知道请求没有经过签名/身份验证,但我什至无法连接到服务器。在继续之前,我至少希望收到一条错误消息,指出我没有经过身份验证。相反,我得到的只是“连接被拒绝”。
我确定我在这里做错了什么。但谷歌一直没用。
【问题讨论】:
-
您是否尝试向您的 URL 添加协议?顺便说一句,您知道 AWS API 都支持 JSON 吗?使用 PHP 更容易。
-
谢谢@scrowler,这正是我需要的答案。
标签: php rest curl amazon-web-services amazon-route53