简体   繁体   English

cURL 亚马逊 aws 拒绝访问

[英]cURL access denied with amazon aws

Trying to download a webcam image using cURL.尝试使用 cURL 下载网络摄像头图像。

The following returns access denied:以下返回拒绝访问:

<?php

$url = 'http://s3-us-west-2.amazonaws.com/alertwildfire-data-public/Axis-CupertinoHills/latest_full.jpg';

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);

header('Content-type: image/jpeg');
echo $data;

The URL comes from this link: URL 来自此链接:

http://www.alertwildfire.org/index.html http://www.alertwildfire.org/index.html

Select region then view webcam and right-click to view image. Select 区域然后查看网络摄像头并右键单击以查看图像。

You need to set the appropriate "Referer" header您需要设置合适的“Referer” header

Example:例子:

curl_setopt($ch, CURLOPT_REFERER, "http://www.alertwildfire.org/blmnv/index.html?camera=Axis-Angel&v=81e002f");

or要么

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Referer: http://www.alertwildfire.org/blmnv/index.html?camera=Axis-Angel&v=81e002f'
));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM