执行MailChimp API v3批处理请求后,它会返回带有响应的.tar.gz文件的URL。
将URL复制/粘贴到浏览器的地址栏中时,文件会立即下载。
但是,当尝试通过PHP cURL下载此文件时,响应为“拒绝访问”。
这是我的PHP cURL脚本:
$_curl = curl_init();
curl_setopt_array($_curl, array(
CURLOPT_URL => $_GET['responseUrl'],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => ''
));
$_response = curl_exec($_curl);
curl_close($_curl);
echo $_response;
这是响应(作为字符串):
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>___someRequestId___</RequestId>
<HostId>___someHostId___</HostId>
</Error>
从命令行curl -v https://...
尝试cURL请求,返回:
[1] 54284
[2] 54285
[2]+ Done Expires=1475609534
* Trying 54.231.40.155...
* Connected to mailchimp-api-batch.s3.amazonaws.com (54.231.40.155) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: *.s3.amazonaws.com
* Server certificate: DigiCert Baltimore CA-2 G2
* Server certificate: Baltimore CyberTrust Root
> GET /c1b0e9e42e-response.tar.gz?AWSAccessKeyId=AKIAJWOH5BECJQZIEWNQ HTTP/1.1
> Host: mailchimp-api-batch.s3.amazonaws.com
> User-Agent: curl/7.49.1
> Accept: */*
>
< HTTP/1.1 403 Forbidden
< x-amz-request-id: E15A53E1C3223996
< x-amz-id-2: UlcIl/cpOwDL9glkG7aho7HEpbskm8f/V56U71yfZWyefyALUHW0bvLFU5iRGiAFb+t2fx/77Fo=
< Content-Type: application/xml
< Transfer-Encoding: chunked
< Date: Tue, 04 Oct 2016 19:35:19 GMT
< Server: AmazonS3
<
<?xml version="1.0" encoding="UTF-8"?>
* Connection #0 to host mailchimp-api-batch.s3.amazonaws.com left intact
<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>E15A53E1C3223996</RequestId><HostId>UlcIl/cpOwDL9glkG7aho7HEpbskm8f/V56U71yfZWyefyALUHW0bvLFU5iRGiAFb+t2fx/77Fo=</HostId></Error>
cURL请求有什么问题?