This article mainly introduces how to obtain and display the QQ profile picture in php and provides two methods for you to choose from. it is a very practical technique, for more information about how to obtain and display a QQ profile by using php, see the following example. 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.