Skip to content

A PHP class that attempts to resolve URLs to a final, canonical link

Notifications You must be signed in to change notification settings

aboustayyef/URLResolver

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to URLResolver.php

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');

About

A PHP class that attempts to resolve URLs to a final, canonical link

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%