Здравствуйте.
Подскажите, как из сокращённой ссылки вытащить конечный URL куда редиректит.
Или хотя бы какие функции использовать и т.п.
Если можно я выложу ссылку пример, либо в ПМ скину.
Заранее спасибо.
@file_get_contents($url);
if(isset($http_response_header) && preg_match('#location:(.*)#i', implode("\r\n", $http_response_header), $m))
$location = trim($m[1]);
else
$location = '';
$url= "URL редиректа";
@file_get_contents($url);
if(isset($http_response_header) && preg_match('#location:(.*)#i', implode("\r\n", $http_response_header), $m));
$location = trim($m[1]);
$locationPerenos = $location."\r\n";
$fp = fopen("1.txt", "at"); // Открываем файл в режиме записи
flock($fp, LOCK_EX); // Блокирование файла для записи
$test = fwrite($fp, $locationPerenos); // Запись в файл
flock($fp, LOCK_UN); // Снятие блокировки
if ($test) echo 'Данные в файл успешно занесены.';
else echo 'Ошибка при записи в файл.';
fclose($fp); //Закрытие файла
@file_get_contents($url);
if(isset($http_response_header) && preg_match('#location:(.*)#i', implode("\r\n", $http_response_header), $m));
$location = trim($m[1]);
$locationPerenos = $location."\r\n";
$file = 'sites.txt';
// Открываем файл для получения существующего содержимого
$current = file_get_contents($file);
// Добавляем новсайт в файл
$current .= $locationPerenos;
// Пишем содержимое обратно в файл
file_put_contents($file, $current);
if(isset($http_response_header) && preg_match('#location:(.*)#i', implode("\r\n", $http_response_header), $m));
Цитата (HellFire @ 1.11.2012 - 23:04) |
Так чтоль делать? |
file_put_contents($file, $locationPerenos, FILE_APPEND);