calthoff
calthoff

Reputation: 386

Amazon SimpleDB PuttAttributes

I am new to both PHP and Amazon SimpleDB. I am trying to figure out how to update values in SimpleDB. I created a signature which returns a value so I believe that is working. When I try to follow Amazon's PutAttribute example, my application breaks. Any hints or ideas of what I could be doing wrong would be greatly appreciated.

$item_name = htmlspecialchars($_POST["item_name"]);
$timestamp = gmdate('c');
$secretkey = 'mysecretkey';
$accesskey = 'myaccesskey';

$message = "
https://sdb.amazonaws.com/
?Action=PutAttributes
&Attribute.1.Name=body_type
&Attribute.1.Value=02
&Attribute.1.Replace=true
&AWSAccessKeyId=[my access key]
&DomainName=FILE_LOG_DEV
&ItemName={$item_name}
&SignatureVersion=2
&SignatureMethod=HmacSHA256
&Timestamp={$timestamp}
&Version=2009-04-15
";


$signature = base64_encode(hash_hmac('sha1', $message, $secretkey, true));

https://sdb.amazonaws.com/
?Action=PutAttributes
&Attribute.1.Name=body_type
&Attribute.1.Value=02
&Attribute.1.Replace=true
&AWSAccessKeyId=[my access key]
&DomainName=FILE_LOG_DEV
&ItemName=$item_name
&SignatureVersion=2
&SignatureMethod=HmacSHA1
&Timestamp=$timestamp
&Version=2009-04-15
&Signature=$signature

Upvotes: 1

Views: 75

Answers (1)

Ashish Pancholi
Ashish Pancholi

Reputation: 4659

You can use AWS PHP SDK (link) that will help you to interact with Amazon SimpleDB Database Service in easy and friendly manner. AWS PHP SDK will internally manage your creating signature and time stamp. So you need to only focus on parameters pass to your method and result what you get from that method. Have a look on example. Here it will take an array as argument and returns a response Model object.

Upvotes: 1

Related Questions