Posted By

pixelsoul on 08/18/10


Tagged

favicon


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

pxqopat-g
leobetosouza


Get domain favicon through Google


 / Published in: PHP
 

URL: http://snipplr.com/view/8120/google-favicon/

A simple function to grab the favicon of a domain using Google s2 Converter. I kept it simple just so it could be changed easily work in a number of different situations.

  1. <?php
  2. // Grab the favicon of a domain using Google s2 Converter
  3. // Put this in your php file and then call it like:
  4. // http://yourdomain.com/file.php?url=somedomain.com
  5.  
  6. function getFavicon(){
  7. $linkurl = $_GET['url'];
  8. $linkurl = str_replace("http://",'',$linkurl); // remove protocol from the domain
  9. $imgurl = "http://www.google.com/s2/favicons?domain=" . $linkurl;
  10. echo '<img src="' . $imgurl . '" width="16" height="16" />';
  11. }
  12.  
  13. getFavicon();
  14. ?>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: bttfmcf on February 22, 2011

You can keap the original URL without removing the protocol with the "domainurl" parameter : http://www.google.com/s2/u/0/favicons?domainurl=http://www.google.com

You need to login to post a comment.