使用Google API检查favicon [英] To check favicon using Google API
本文介绍了使用Google API检查favicon的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们如何检查谷歌API提供的favicon是默认的地球仪?
$ b https://www.google.com/s2/u/0/favicons?domain=facebook.com 会返回 facebook
,其中 https://www.google.com/s2/u/0/favicons?domain=test.com 将地球仪作为图标返回。
我们如何检查favicon是否为default globe?
解决方案
我做了一个函数,
$ b
函数getFavicon($ domain){
$ data = file_get_contents('https:// plus.google.com/_/favicon?domain='。$ domain);
$ base64 = base64_encode($ data);
return($ data&& hash('md5',$ base64)!=='99fd8ddc4311471625e5756986002b6b'?'data:image / png; base64,'。$ base64:false);
}
$ favicon = getFavicon('facebook.com');
if($ favicon){
echo'< img src =''。$ favicon。'/>';
}
How can we check favicon provided by Google API is the default globe?
https://www.google.com/s2/u/0/favicons?domain=facebook.com returns the favicon of the facebook
, where as https://www.google.com/s2/u/0/favicons?domain=test.com returns the globe as the favicon.
How can we check if the favicon is default globe or not?
解决方案
I made a function a while back what checks if the default globe icon is returned.
function getFavicon($domain) {
$data = file_get_contents('https://plus.google.com/_/favicon?domain=' . $domain);
$base64 = base64_encode($data);
return ($data && hash('md5', $base64) !== '99fd8ddc4311471625e5756986002b6b' ? 'data:image/png;base64,' . $base64 : false);
}
$favicon = getFavicon('facebook.com');
if ( $favicon ) {
echo '<img src="' . $favicon . '" />';
}
这篇关于使用Google API检查favicon的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文