Subject: | Shorl & TinyURL changes |
Both Shorl and TinyURL have changed their access to URLs. Shorl now use a intermmediate page and TinyURL use 'forwarding' as a subdomain instead of 'redirecting'. The file here patches Shorl.pm and tinyurl.t.#
In addition please note that 'http://perl.dellah.org/WWW-Shorten-1.5.2.tar.gz' is now returning a 404 HTTP error, and as such notlong.t now fails. On further investigation, the page that notlong.com sends back contains the phrase 'Check the long URL: 404 Not Found', so you might want to check for this in future versions and return undef.
--- C:\wip\diffs\WWW-Shorten\WWW-Shorten-1.93/lib/WWW/Shorten/Shorl.pm Sat Oct 30 13:52:01 2004
+++ C:\wip\diffs\WWW-Shorten\WWW-Shorten-1.93-barbie/lib/WWW/Shorten/Shorl.pm Mon Jan 17 12:30:27 2005
@@ -91,10 +91,12 @@
unless $shorl_url =~ m!^http://!i;
my $resp = $ua->get($shorl_url);
+ return unless $resp->is_success;
- return undef unless $resp->is_redirect;
- my $url = $resp->header('Location');
- return $url;
+ if ($resp->content =~ m!<meta HTTP-EQUIV="Refresh" CONTENT="[0-9]+\; URL=(.*)"!i) {
+ return $1;
+ }
+ return;
}
--- C:\wip\diffs\WWW-Shorten\WWW-Shorten-1.93/t/tinyurl.t Tue Oct 26 21:24:24 2004
+++ C:\wip\diffs\WWW-Shorten\WWW-Shorten-1.93-barbie/t/tinyurl.t Mon Jan 17 12:00:44 2005
@@ -5,7 +5,7 @@
my $url = 'http://perl.dellah.org/WWW-Shorten-1.5.2.tar.gz';
my $code = '2etu';
my $prefix = 'http://tinyurl.com/';
-my $prefix2 = 'http://redirecting.tinyurl.com/redirect.php?num=';
+my $prefix2 = 'http://forwarding.tinyurl.com/redirect.php?num=';
is ( makeashorterlink($url), $prefix.$code, 'make it shorter');
is ( makealongerlink($prefix.$code), $prefix2.$code, 'make it longer');
is ( makealongerlink($code), $prefix2.$code, 'make it longer by Id',);