0

我正在尝试使用 PHP 和官方 Amazon AWS PHP SDK 从 SimpleDB 获取域列表。我的代码得到了一些东西,但它似乎在循环错误的东西。

这是我的代码:

<?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>";

?>

我得到以下输出的那一刻

Domain: 
Domain: test05
Domain: 

我应该得到:

test05
test06
test07
4

1 回答 1

1

这比我想象的要容易。有一个更容易使用的命令:

这是代码:

<?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>";
}
?>
于 2012-09-02T08:49:32.257 回答