Php obtains and displays the QQ avatar. php obtains the QQ avatar _ PHP Tutorial.

Source: Internet
Author: User
Php obtains and displays the QQ avatar. php obtains the QQ avatar. Php obtains and displays the QQ avatar. This article describes how php obtains and displays the QQ avatar. Share it with you for your reference. The specific analysis is as follows: I recently saw php's method of getting and displaying the QQ avatar. php's method of getting the QQ avatar

This example describes how to obtain and display a QQ profile by using php. Share it with you for your reference. The specific analysis is as follows:

Recently, the headers of blog posts are a bit awkward, because they all share the same profile picture, which is not very comfortable. Although most of the themes are now integrated with the Gavatar Avatar function, I did not get a gavatar Avatar myself, not to mention the problem of gavatar being walled.

Because I have logged on several times and the connection speed is very slow, I gave up. of course, there are too many message plug-ins to list. for example, it's a bit popular to say it now, but for friends who haven't registered many words, the Avatar is still a problem. for more social account binding, I have tested it for many times. QQ and Renren often encounter errors in binding to mainstream platforms, and some friends hate tedious authorization.

In view of this, I am thinking about 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 is at least one person now, therefore, you only need to enter the QQ number when leaving a message, and then call its avatar, which makes it much easier.

The first step is to get QQ's profile picture, which is the first step of this idea, that is, today's topic.

The code for the first method is as follows:

The code is as follows:

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


The code for the second method is as follows:

The code is as follows:

<? 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 you can output the source image of the avatar. if your avatar is a dynamic gif, the output is also a dynamic image. The disadvantage is that the speed is slow, this method is not suitable for calling the 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.

I hope this article will help you with php programming.

The example in this article describes how php obtains and displays the QQ avatar. Share it with you for your reference. The specific analysis is as follows...

Related Article

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.