Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Retrive destination url of a redirection page?
Old 04-21-2007, 02:24 PM Retrive destination url of a redirection page?
Junior Talker

Posts: 2
Trades: 0
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.
aaijay is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-24-2007, 08:51 AM Re: Retrive destination url of a redirection page?
solomongaby's Avatar
Webmaster Talker

Latest Blog Post:
How Do You Find Music Online ?
Posts: 522
Name: Gabe Solomon
Location: Romania
Trades: 1
do a echo $data .. before preg_match ... to see all the data
__________________
If you like my posts ... TK is appreciated:)

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
solomongaby is offline
Reply With Quote
View Public Profile Visit solomongaby's homepage!
 
Reply     « Reply to Retrive destination url of a redirection page?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09965 seconds with 12 queries