我在 AWS EC2 上有一个 LAMP 服务器,并且我已经使用 Composer 安装了适用于 PHP 2 的 AWS 开发工具包,就像此处的说明一样。
我正在尝试运行示例查询以在 DynamoDB 上插入一些项目,但我在 PHP 上收到以下错误:
PHP 致命错误:调用未定义的方法 Guzzle\Http\Message\Request::batchWriteItem()
我的代码:
require "vendor/autoload.php";
use Aws\DynamoDb\DynamoDbClient;
use Aws\Common\Enum\Region;
// Instantiate the DynamoDB client with your AWS credentials
$aws = DynamoDbClient::factory(array(
'key' => 'xxx',
'secret' => 'xxx',
'region' => Region::US_WEST_2
));
$client = $aws->get("dynamodb");
$tableName = "xxxx";
$response = $client->batchWriteItem(array(
"RequestItems" => array(
$tableName => array(
array(
"PutRequest" => array(
"Item" => array(
"IP" => array(Type::STRING => "203.203.203.22"),
"APIKEY" => array(Type::STRING => "jkhkjhskjhs"),
"TIMESTAMP" => array(Type::STRING => time()),
"PostedBy" => array(Type::STRING => "User B")
)
)
)
),
)
));
想法???
谢谢!