PHP get QQ Avatar and display the method _php tutorial

Source: Internet
Author: User

PHP get QQ Avatar and display the method


Recently saw the blog post the avatar a bit awkward, because the visitor's avatar is the same head, looking not very comfortable. Although the majority of the theme now integrates the Gavatar avatar function, do not say Gavatar was the wall of the problem, I do not now have a gavatar avatar.

Because I landed a few times, the connection speed is very slow, so I gave up, of course, the message plugin also abound, for example, now more fire more say, but for not registered more said friends, Avatar is still a problem, for many said social account binding, I test many times, QQ, everyone these mainstream platform bindings often error, And some friends hate the cumbersome authorization.

In view of this, I am thinking of a popular, relatively simple method, I think of a friend who has no avatar to call their QQ avatar, because QQ is now at least one hand, so only need to fill in the message when the QQ number, and then call its avatar, so it is more convenient.

The first is to get the head of QQ, this is the first step of the idea, that is, the theme of today.

The first method, the code is as follows:

The code is as follows:

$QQ = 123456789;
Echo ';
?>


The second method, the code is as follows:

The code is as follows:

$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 you can output the original picture, if your avatar is a dynamic gif, then the output is also a dynamic graph, the disadvantage is that the speed is relatively slow, not suitable as a method to call the avatar.

The advantage of the second method is that it is faster than the first, but only the static diagram of the avatar is captured, and the dynamic avatar is not displayed, which is more suitable as a method to call the avatar.

http://www.bkjia.com/PHPjc/931946.html www.bkjia.com true http://www.bkjia.com/PHPjc/931946.html techarticle PHP get QQ Avatar and display the method recently see blog message avatar a bit awkward, because the visitor's avatar is the same head, looking not very comfortable. Although most of the themes are now ...

  • 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.