Share two ways to get QQ avatar using php.
Method 1:
<?php
$qq=12345678;
echo '<img src="'.'http://q1.qlogo.cn/g?b=qq&nk='.$qq.'&s=100&t='.time().'">';
Copy after login
Method 2:
<?php
$qq=12345678;
$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);
Copy after login
The difference between these two methods:
The advantage of method one is that it can output the original image of the avatar. If your avatar is a dynamic gif, then the output will also be a dynamic image. The disadvantage is that it is relatively slow and not suitable as a method for calling avatars.
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 to call the avatar.
Articles you may be interested in
- The reason why PHP adds backslashes before quotation marks and how to remove backslashes in PHP, three ways to close php magic quotes
- PHP uses header() to implement file download. The downloaded file prompts that it is damaged and cannot be opened.
- PHP implements sharing SESSION data with multiple second-level domain names on the same server
- php obtains a certain Method for each month within a period of time, returns an array composed of these months
- php clears (delete) the files in the specified directory, method without deleting the directory folder
- php gets today and tomorrow Summary of N methods for yesterday’s timestamp
- PHP analyzes file header information to determine the type of uploaded file
- Three methods for PHP to obtain the client’s real IP address
http://www.bkjia.com/PHPjc/764113.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/764113.htmlTechArticleShare two ways to get QQ avatar using php. Method 1: ?php$qq=12345678;echo 'img src="'.'http://q1.qlogo.cn/g?b=qqnk='.$qq.'s=100t='.time() .'"'; Method 2: ?php$qq=1234567...