我正试图使用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>";
?>
A当我得到以下输出时
Domain:
Domain: test05
Domain:
我应该得到:
test05
test06
test07
这比我想象的要容易。有一个更容易使用的命令:
这是代码:
<?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>";
}
?>