im tryng to gain the redirected url of lets say
http://www.dailymotion.com/swf/maX6GkyCdEPSl9n5j
so my code is
Code:
<?php
error_reporting(E_ALL);
$service_port = getservbyname('www', 'tcp');
$address = gethostbyname('dailymotion.com');
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket < 0) {
echo "socket_create() failed: reason: " . socket_strerror($socket) . "\n";
}
$result = socket_connect($socket, $address, $service_port);
if ($result < 0) {
echo "socket_connect() failed.\nReason: ($result) " . socket_strerror($result) . "\n";
}
$in = "GET /swf/2nWJZC4oOeGTLbZm1 HTTP/1.0\r\n";
$in .= "Host: dailymotion.com\r\n";
$in .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1\r\n";
$in .= "Accept: text/xml,application/xml,application/x-shockwave-flash,application/xhtml+xml,text/html;text/plain\r\n";
//$in .= "Accept: application/x-shockwave-flash\r\n";
$in .= "Accept-Language: en-us,en\r\n";
$in .= "Accept-Charset: ISO-8859-1,utf-8\r\n";
$in .= "Connection: Close\r\n\r\n";
$out = '';
$data = '';
socket_write($socket, $in, strlen($in));
while ($out = socket_read($socket, 2048)) {
$data .= $out;
}
socket_close($socket);
preg_match("/Location: (.*)\r\n/", $data, $matches);
//$test = preg_match("/http:\/\/www\.dailymotion\.com\/flash\/flvplayer\.swf\?(.*)+/", $data, $matches);
echo $matches[1];
//echo $test;
?>
which just returns the Main page url not the redirected one
any help please.
thanks in advance.
|