<?php

include_once("r53.class");

function log_error($l){
	printf("LOG: %s\n", $l);
	return true;
}


main:

# Pass this your public and private keys
$r53 = new Route53("PUBKEY","PRIVKEY");
$apiurl = $r53->getApiUrl("ZONEID");
$xmlreq = $r53->getRequestBody("domain.example.com", "8.8.8.8", "3600","A");
log_error(sprintf("XMLHASH:%s",  hash("sha256",$xmlreq)));
$httphead = $r53->getHttpPostHeaders("ZONEID", "us-east-1", hash("sha256",$xmlreq));

if(true){
	log_error(sprintf("Sending reuquest to: %s", $apiurl));
	foreach($httphead as $hv){
		log_error(sprintf("Header: %s", $hv));
	}
	log_error(sprintf("XMLPOST: %s", $xmlreq));
}


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiurl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $httphead);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlreq);

print curl_exec($ch);
print "\n";
curl_close($ch);

?>
