Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用amazon aws拒绝cURL访问_Php_Curl - Fatal编程技术网

Php 使用amazon aws拒绝cURL访问

Php 使用amazon aws拒绝cURL访问,php,curl,Php,Curl,正在尝试使用cURL下载网络摄像头图像 以下返回拒绝的访问: <?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_CONNECTTIMEOU

正在尝试使用cURL下载网络摄像头图像

以下返回拒绝的访问:

<?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;

您需要设置适当的“Referer”标题

例如:

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

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