About This Sample
- A PHP Query API sample to demonstrate creating a queue, sending messages, receiving messages, and deleting messages.
- Based on the 2008-01-01 API version (Query).
- Based on Amazon SQS Sample in PHP by Justin@AWS
- Minor improvements made to increase performance and to drop dependencies of
- PEAR::HTTP_Request has been replaced by CURL or HTTP URL Wrappers, depending on availability
- PEAR::Crypt_HMAC has been replaced by hash or mhash PECL, depending on availability
- A standalone HMAC function has been included, so the library can run without hash or mhash PECL
- The library uses POST mode rather than GET if the query string is longer than 1k
- The HMAC conversion from hexadecimal to binary is done with pack(), rather than with a for-loop
- PHPDoc blocks have been added
The PHP sample code includes an example file called
sqs.test.php that performs basic SQS actions. We explain how to run that example. We also walk through the contents of that file. After you're familiar with the contents of
sqs.test.php, you can modify the file as you'd like to suit your needs.
- You must have a valid Amazon Web Services developer account (go to http://aws.amazon.com to sign up for one).
- You must be signed up to use Amazon SQS (go to http://aws.amazon.com/sqs to sign up for the service).
- PHP 5, which includes access to the SimpleXML extension (to download it, go to http://php.net)
- Requires either CURL or HTTP URL Wrapper for HTTP communication
- For HMAC, makes use of hash or mhash PECL functions, or falls back on a standalone function using sha1() if not available.
Running the Sample
- Enter your AWS credentials in sqs.test.php.
- Open sqs.test.php.
- Note: initial page load may take a few seconds as a new queue will be created.