return error if ebay returns other than 200
This commit is contained in:
parent
ce30653d3b
commit
1e8ed63c24
|
@ -1,16 +1,22 @@
|
|||
<?php
|
||||
if(!array_key_exists("url", $_GET) || $_GET["url"] == "") {
|
||||
if (!array_key_exists("url", $_GET) || $_GET["url"] == "") {
|
||||
die("URL not set or empty");
|
||||
}
|
||||
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, "https://i.ebayimg.com/" . $_GET["url"]);
|
||||
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt ($curl, CURLOPT_CONNECTTIMEOUT, 20);
|
||||
curl_setopt ($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
|
||||
curl_setopt ($curl, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 20);
|
||||
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
|
||||
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
|
||||
|
||||
$content = curl_exec ($curl);
|
||||
$contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE);
|
||||
header('Content-Type: ' . $contentType);
|
||||
echo($content);
|
||||
$content = curl_exec($curl);
|
||||
$httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
|
||||
if ($httpcode == 200) {
|
||||
$contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE);
|
||||
header('Content-Type: ' . $contentType);
|
||||
echo ($content);
|
||||
} else {
|
||||
die("Page not Found.");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue