mardi 28 avril 2015

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://ift.tt/1DUMLB6

<?php
$baseurl = "http://ift.tt/1GG2CdU";
$body = '<?xml version="1.0" encoding="UTF-8"?>
    <CreateReusableDelegationSetRequest xmlns="http://ift.tt/1xMuWCf">
       <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.




Aucun commentaire:

Enregistrer un commentaire