I use this command to get headers back from this specific page.
curl -I https://www.gearbest.com/mobile-phones/pp_1686789.html?wid=1817324
i run the above command from terminal and i get these results...
HTTP/2 200
content-type: text/html; charset=UTF-8
pragma: public
last-modified: Fri, 02 Nov 2018 18:15:13 GMT
gbcdnlang: en
access-control-allow-origin: *
access-control-allow-methods: GET, POST
ng-cache: HIT
x-edgeconnect-midmile-rtt: 36
x-edgeconnect-origin-mex-latency: 137
cache-control: public, max-age=60
expires: Fri, 02 Nov 2018 23:39:15 GMT
date: Fri, 02 Nov 2018 23:38:15 GMT
set-cookie: ORIGINDC=3;Domain=.gearbest.com;Path=/
set-cookie: ORIGINDCPC=3;Domain=.gearbest.com;Path=/
set-cookie: AKAM_CLIENTID=d51abedb38c60f8a5217ae15808769fc; expires=Mon, 31-Dec-2038 23:59:59 GMT; path=/; domain=.gearbest.com
vary: User-Agent
So far so good. But when i try to implement in php using the code below i get "URL not exists" ! What am i doing wrong? Any help appreciated.
$url1 = "https://www.gearbest.com/mobile-phones/pp_1686789.html?wid=1817324";
$curl1 = curl_init($url1);
curl_setopt($curl1, CURLOPT_NOBODY, true);
curl_setopt($curl1, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($curl1, CURLOPT_TIMEOUT, 5); //timeout in seconds
$result1 = curl_exec($curl1);
if ($result1 !== false)
{
$statusCode1 = curl_getinfo($curl1, CURLINFO_HTTP_CODE);
if ($statusCode1 == 404)
{
echo "URL Not Exists";
}
else
{
echo "URL Exists";
}
}
else
{
echo "URL not Exists";
}