php获取QQ头像的方法

WBOY
Release: 2016-06-20 13:05:11
Original
1452 people have browsed it

使用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>
Copy after login

方法二:

$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>
Copy after login

这两种方法的区别:

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

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


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!