Home > Backend Development > PHP Tutorial > How to get QQ avatar in php and display it, get qq avatar in php_PHP tutorial

How to get QQ avatar in php and display it, get qq avatar in php_PHP tutorial

WBOY
Release: 2016-07-13 10:10:56
Original
1088 people have browsed it

How to get QQ avatar in php and display it, get qq avatar in php

The example in this article describes the method of obtaining QQ avatar and displaying it in php. Share it with everyone for your reference. The specific analysis is as follows:

Recently, I saw that the avatars in blog comments are a bit awkward, because the avatars of visitors all have the same avatar, which is not very comfortable to look at. Although most themes now integrate the Gavatar avatar function, let’s not talk about the issue of gavatar being blocked. I haven’t even gotten a gavatar avatar myself yet.

Because I logged in several times and the connection speed was extremely slow, I gave up. Of course, there are countless message plug-ins. For example, the popular Duodao is now, but for friends who have not registered Duodao, the avatar is still a problem. , I have tested Duosuo’s social account binding many times, QQ, Renren and other mainstream platforms often make mistakes, and some friends hate cumbersome authorization.

In view of this, I am thinking of a popular and relatively simple method. What I am thinking of is to call the QQ avatar of friends who do not have avatars. Because QQ now has at least one for everyone, so you only need to fill in the QQ number when leaving a message, and then Call its avatar, which will be much more convenient.

The first thing is to get the QQ avatar. This is also the first step of this idea, which is today’s topic.

The first method, the code is as follows:

Copy code The code is as follows:
$qq = 123456789;
echo '';
?>

The second method, the code is as follows:
Copy code 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 these two methods:

The advantage of the first method is that it can output the original image of the avatar. If your avatar is a dynamic gif, then the output is also a dynamic image. The disadvantage is that it is relatively slow and is not suitable as a method to call the avatar.

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

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/932077.htmlTechArticleHow to get QQ avatar in php and display it, how to get qq avatar in php and display it in this example method. Share it with everyone for your reference. The specific analysis is as follows: Recently I saw...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template