How to obtain and display the QQ profile picture in php
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.