Example of php getting and displaying the QQ avatar

Source: Internet
Author: User

Because I log on several times and the connection speed is very slow, I gave up. Of course, there are too many message plug-ins. For example, it's a bit of a hot talk now, but it's still a problem for friends who haven't registered many words. For more social account binding, I have tested many times, QQ, and Renren. Binding to mainstream platforms often fails, and some friends (like me) hate tedious authorization.

In view of this, I am thinking of a popular and simple method. I think of a friend who does not have a profile picture to call his QQ profile picture. Because QQ now has at least one person, I only need to enter the QQ number when leaving a message and then call his profile picture. This makes it much easier.

The first step is to get the avatar of QQ, which is also the first step of this idea, that is, today's topic:

Method 1:

The code is as follows: Copy code

<? Php
$ Qq = 552452006;
Echo ' ';
?>

Method 2:

The code is as follows: Copy code

<? Php
$ Qq = 552452006;
 
$ Src = 'http: // q1.qlogo.cn/g? B = qq & nk = '. $ qq.' & s = 100 & t = '. time ();
 
Header ('content-type: image/png ');
 
$ Res = imagecreatefromstring (file_get_contents ($ src ));
 
Imagepng ($ res );
 
Imagedestroy ($ res );
?>

The difference between the two methods:

The advantage of the first method is that the source image of the avatar can be output. If your avatar is a dynamic gif, the output is also a dynamic image. The disadvantage is that it is slow and is not suitable for calling avatar.

The advantage of the second method is that it is faster than the first method, but it only captures the static graph of the Avatar and does not display the dynamic avatar. It is more suitable for calling the Avatar method.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.