Home  >  Article  >  Backend Development  >  php获取QQ头像的方法

php获取QQ头像的方法

WBOY
WBOYOriginal
2016-06-20 13:05:111453browse

使用php获取QQ头像的方法分享。

方法一:

<p><?php</p>$qq=1290026290;<br /><p>echo '<img  src="'.'http://q1.qlogo.cn/g?b=qq&nk='.$qq.'&s=100&t='.time().'" alt="php获取QQ头像的方法" >';</p>

方法二:

$qq=1290026290;<br />$src='http://q1.qlogo.cn/g?b=qq&nk='.$qq.'&s=100&t='.time();<br />header('Content-type: image/png');<br />$res=imagecreatefromstring(file_get_contents($src));<br />imagepng($res);<br /><p>imagedestroy($res);</p>

这两种方法的区别:

方法一的优点是可以输出头像的原图,如果你的头像是动态的gif,那么输出的也是动态图。缺点是速度比较慢,不适合作为调用头像的方法。

方法二的优点是相比第一种速度比较快,但只抓取头像的静态图,不会显示动态头像,比较适合作为调用头像的方法。


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn