Trying to download a webcam image using 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:
http://www.alertwildfire.org/index.html
Select region then view webcam and right-click to view image.
You need to set the appropriate "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'
));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.