Возьмите библиотеки типа
Guzzle или хотя бы просто
curl.
Они более корректно работают с протоколом HTTP, чем file_get_contents
curl<?php
$link = "http://www.aliexpress.com/item/Wholesale-price-free-shipping-good-quality-high-clear-phone-back-screen-protect-film-For-Huawei-Ascend/32258530279.html";
$ch = curl_init();
curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1" );
curl_setopt( $ch, CURLOPT_URL, $link );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch, CURLOPT_ENCODING, "" );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_AUTOREFERER, true );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
$ali = curl_exec( $ch );
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
if ($error) // ошибка curl, например таймаут
{
echo 'CURL error occurred during the request: ' . $error;
echo "\n";
} elseif ($http_code<200 || $http_code>=300) // код возврата не 200
{
echo 'HTTP error ' . $http_code. ' occurred during the request';
echo "\n";
var_dump(curl_getinfo( $ch )); // там все заголовки и другая отладочная информация
} else
{
print_r($ali);
}
Guzzle$client = new GuzzleHttp\Client();
$res = $client->get('http://www.aliexpress.com/item/Wholesale-price-free-shipping-good-quality-high-clear-phone-back-screen-protect-film-For-Huawei-Ascend/32258530279.html');
echo $res->getStatusCode();
// "200"
echo $res->getHeader('content-type');
// 'text/htm; charset=utf8'
echo $res->getBody();
// <html ...