aboustayyef/url-resolver

Redirects to final url

dev-master 2015-09-29 15:58 UTC

This package is not auto-updated.

Last update: 2024-05-01 16:43:36 UTC


README

This is a fork of URL Resolver by Matt Wright and contributors that works with composer and conforms to psr-4.

URLResolver.php is a PHP class that attempts to resolve URLs to a final, canonical link. On the web today, link shorteners, tracking codes and more can result in many different links that ultimately point to the same resource. By following HTTP redirects and parsing web pages for open graph and canonical URLs, URLResolver.php attempts to solve this issue.

Patterns Recognized

  • Follows 301, 302, and 303 redirects found in HTTP headers
  • Follows Open Graph URL <meta> tags found in web page <head>
  • Follows Canonical URL <link> tags found in web page <head>
  • Aborts download quickly if content type is not an HTML page

I am open to additional suggestions for improvement.

Usage

Resolving a URL can be as easy as:

	use Resolver\URLResolver ;

	$resolver = new URLResolver();

	$resolver->isDebugMode(true);
	$resolver->setMaxRedirects(10);
	$resolver->setCookieJar('/mycookie.cookie');
	$resolver->setUserAgent('Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36');
	$resolver->resolveURL('http://t.co/Hb6cX2JyGM');