im tryng to gain the redirected url of lets say
http://www.dailymotion.com/swf/maX6GkyCdEPSl9n5j
so my code is
<?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.0rn";
$in .= "Host: dailymotion.comrn";
$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.1rn";
$in .= "Accept: text/xml,application/xml,application/x-shockwave-flash,application/xhtml+xml,text/html;text/plainrn";
//$in .= "Accept: application/x-shockwave-flashrn";
$in .= "Accept-Language: en-us,enrn";
$in .= "Accept-Charset: ISO-8859-1,utf-8rn";
$in .= "Connection: Closernrn";
$out = '';
$data = '';
socket_write($socket, $in, strlen($in));
while ($out = socket_read($socket, 2048)) {
$data .= $out;
}
socket_close($socket);
preg_match("/Location: (.*)rn/", $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