George43g
George43g

Reputation: 623

Trying to make an API request using PHP with AWS Route53

I need to make one API request to AWS Route53 to create a reusable delegation set. You can't do this through the console web interface, it has to be through the API.

Here is the documentation for making this API request: 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);

?>

I know the request isn't signed/authenticated, but I'm not even able to connect to the server. I would at least like to get an error message that says I'm not authenticated before I continue. Instead all I get is "connection refused".

I'm sure I'm doing something completely wrong here. But Google has been of no use.

Upvotes: 2

Views: 1084

Answers (1)

George43g
George43g

Reputation: 623

scrowler was right. I changed:

$baseurl = "route53.amazonaws.com/2013-04-01/delegationset";

to

$baseurl = "https://route53.amazonaws.com/2013-04-01/delegationset";

I got the error message I was expecting and now I can work on the next step.

Upvotes: 1

Related Questions