how to retrieve S3-hosted images with PHP+CURL without getting SignatureDoesNotMatch?
I've got a PHP-managed site that is pulling content from a Posterous blog via an RSS feed. In this feed are images with Posterous URLs, but when I retrieve them they redirect to Amazon S3 URLs.
Within php I'm using curl to try to pull the images and cache them locally, using code from PHP's CURL manual page: http://www.php.net/manual/en/ref.curl.php#93163 verbatim. It handles the redirects to S3 some of the time, but unpredictably, instead of retrieving the image, it will re开发者_Go百科turn an XML file with a SignatureDoesNotMatch error.
What causes this? And what can I do to prevent the error?
If the failures are intermittent, it's probably something to do with the file(key) names. A common culprit is spaces in the filenames.
You'll need to URL Encode them or replace spaces with %20
From what I understand SignatureDoesNotMatch is the error you get when you are not authorised to access the resource. are you providing the necessary credentials?
精彩评论