AmazonS3在php中的实现不起作用

AmazonS3在php中的实现不起作用,php,amazon-web-services,amazon-s3,Php,Amazon Web Services,Amazon S3,我正在尝试集成亚马逊api直接上传内容。当我整合这个时,我得到了一个错误: $aws_key = example key; $aws_secret = example secret key; $source_file = 'test.jpg'; // file to upload to S3 $file_type = "image/jpg"; // or other file type like "image/jpeg" for JPEG image, // or "binary/

我正在尝试集成亚马逊api直接上传内容。当我整合这个时,我得到了一个错误:

$aws_key    = example key;
$aws_secret = example secret key;

$source_file = 'test.jpg'; // file to upload to S3

$file_type = "image/jpg";  // or other file type like "image/jpeg" for JPEG image, 
// or "binary/octet-stream" for binary file

$aws_bucket = 'bucket_example'; // AWS bucket 
$aws_object = 'test.jpg';         // AWS object name (file name)


if (strlen($aws_secret) != 40) die("$aws_secret should be exactly 40 bytes long");
$file_data = file_get_contents($source_file);
if ($file_data == false) die("Failed to read file ".$source_file);


// opening HTTP connection to Amazon S3
$fp = fsockopen("s3.amazonaws.com", 80, $errno, $errstr, 30);
if (!$fp) {
    die("$errstr ($errno)\n");
}
我得到了这个错误:

AmazonS3 2eb签名不匹配我们计算的请求签名与您提供的签名不匹配。检查您的密钥和签名方法


我仔细检查了钥匙。钥匙没有错。

您在哪里为亚马逊提供钥匙?你只是在那里打开套接字,没有任何数据。我建议使用官方软件与Amazon S3集成。同意@JeremyLindblom。下面是示例用法:如果您想要更简单的示例,请参阅本文: