Php 使用amazon aws拒绝cURL访问
正在尝试使用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
<?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'
));