0

I'm trying to get a list of domains from SimpleDB using PHP and the official Amazon AWS PHP SDK. My code gets something, but it seems to be looping through the wrong stuff.

Here is my code:

<?php
// Include the SDK
require_once 'sdk.class.php';

// Include the SDK
$sdb = new AmazonSDB();

$domainList = $sdb->listDomains();

echo "<pre>";
print_r($domainList, false);
echo "</pre>";

echo "<br><br><br>";

if ($domainList) {
  foreach ($domainList as $domainName) {

    $domain_name = $domainName->ListDomainsResult->DomainName;
    echo "Domain: " . $domain_name . "<br>";

  }
}

echo "<br><br><br>";

$request_id = $response->body->ResponseMetadata->RequestId;
$cost = $response->body->ResponseMetadata->BoxUsage;

echo "Request ID: " . $request_id . "<br>";
echo "Cost: " . $cost . "<br>";

?>

A the moment I get the following output

Domain: 
Domain: test05
Domain: 

I should get:

test05
test06
test07
andrebruton
  • 2,268
  • 4
  • 29
  • 36

1 Answers1

1

It is easier than I thought. There is an easier command to use:

Here is the code:

<?php
// Include the SDK
require_once 'sdk.class.php';

// Include the SDK
$sdb = new AmazonSDB();

// Get list of domains
$domains = $sdb->get_domain_list();

// echo "<pre>";
// print_r($domains, false);
// echo "</pre>";

foreach ($domains as $domain)
{ 
  echo "Domain: " . $domain . "<br>";
}
?>
andrebruton
  • 2,268
  • 4
  • 29
  • 36