I want to get, requested website\'s favicon with PHP. I have been recommended using Google\'s favicon service but it is not functional. I want to do something on my own but
See this answer : https://stackoverflow.com/a/22771267. It's an easy to use PHP class to get the favicon URL and download it, and it also gives you some informations about the favicon like file type or how the favicon was found (default URL, tag...) :
icoExists){
echo "Favicon found : ".$favicon->icoUrl."\n";
// Saving favicon to file
$filename = 'favicon-'.time().'.'.$favicon->icoType;
file_put_contents($filename, $favicon->icoData);
echo "Saved to ".$filename."\n\n";
} else {
echo "No favicon for ".$favicon->url."\n\n";
}
$favicon->debug();
/*
FaviconDownloader Object
(
[url] => https://code.google.com/p/chromium/issues/detail?id=236848
[pageUrl] => https://code.google.com/p/chromium/issues/detail?id=236848
[siteUrl] => https://code.google.com/
[icoUrl] => https://ssl.gstatic.com/codesite/ph/images/phosting.ico
[icoType] => ico
[findMethod] => head absolue_full
[error] =>
[icoExists] => 1
[icoMd5] => a6cd47e00e3acbffffd2e8a760dfe64cdc
)
*/
?>