Table of Contents
php获取QQ头像并显示的方法,php获取qq头像
Home php教程 php手册 php获取QQ头像并显示的方法,php获取qq头像

php获取QQ头像并显示的方法,php获取qq头像

Jun 13, 2016 am 09:18 AM
php qq

php获取QQ头像并显示的方法,php获取qq头像

本文实例讲述了php获取QQ头像并显示的方法。分享给大家供大家参考。具体分析如下:

最近看到博客留言的头像有点别扭,因为游客的头像都是同一个头像,看着不是很舒服。虽然现在绝大多数的主题集成了Gavatar头像功能,先不说gavatar被墙的问题,我自己现在都没弄个gavatar头像.

因为我登陆了几次,连接速度巨慢,所以我就放弃了,当然留言插件也不胜枚举,比如现在比较火的多说,但对于没有注册多说的朋友,头像仍是个问题,对于多说的社交账号绑定,我测试多次,QQ,人人这些主流平台的绑定经常出错,而且有的朋友讨厌繁琐的授权.

鉴于此,我在想一个大众化的,比较简单的方法,我想到的是对于没有头像的朋友调用其QQ头像,因为QQ现在至少是人手一个,所以只需要留言时填写QQ号,然后调用其头像,这样一来就方便多了.

首先是获取QQ的头像了,这也是这个想法的第一步,即今天的主题.

第一种方法,代码如下:

复制代码 代码如下:

$qq = 123456789;
echo 'php获取QQ头像并显示的方法,php获取qq头像';
?>


第二种方法,代码如下:

复制代码 代码如下:

$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);
?>


这两种方法的区别:

第一种方法的优点是可以输出头像的原图,如果你的头像是动态的gif,那么输出的也是动态图,缺点是速度比较慢,不适合作为调用头像的方法.

第二种方法的优点是相比第一种速度比较快,但只抓取头像的静态图,不会显示动态头像,比较适合作为调用头像的方法.

希望本文所述对大家的php程序设计有所帮助。

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What software can make Bitcoin? Top 10 Bitcoin Trading Software Recommendations in 2025 What software can make Bitcoin? Top 10 Bitcoin Trading Software Recommendations in 2025 Feb 21, 2025 pm 09:30 PM

With the rapid development of the Bitcoin market, it is crucial to choose reliable trading software. This article will recommend the top ten Bitcoin trading software in 2025 to help you trade efficiently and safely. These software have been rigorously screened and consider factors such as functionality, security, user-friendliness and support levels. From beginner-friendly platforms to complex tools for experienced traders, you will find the best options for your trading needs in this list.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

The latest price of Bitcoin in 2018-2024 USD The latest price of Bitcoin in 2018-2024 USD Feb 15, 2025 pm 07:12 PM

Real-time Bitcoin USD Price Factors that affect Bitcoin price Indicators for predicting future Bitcoin prices Here are some key information about the price of Bitcoin in 2018-2024:

gateio exchange app old version gateio exchange app old version download channel gateio exchange app old version gateio exchange app old version download channel Mar 04, 2025 pm 11:36 PM

Gateio Exchange app download channels for old versions, covering official, third-party application markets, forum communities and other channels. It also provides download precautions to help you easily obtain old versions and solve the problems of discomfort in using new versions or device compatibility.

Summary of essential software for 2025 currency circle Summary of essential software for 2025 currency circle Feb 21, 2025 pm 09:42 PM

This guide provides an overview of the essential software tools in the currency circle that helps users manage and trade crypto assets more efficiently. These software cover a wide range of categories from trading platforms to analytical tools and security solutions. The guide is designed to help users prepare for the upcoming crypto market in 2025.

Which is the best market viewing software? Top 10 virtual currency exchange market viewing software Which is the best market viewing software? Top 10 virtual currency exchange market viewing software Feb 21, 2025 pm 09:48 PM

For those engaged in virtual currency trading, choosing an excellent market viewing software is crucial. This article aims to introduce readers to the ten most acclaimed virtual currency exchange viewing software to help them make informed choices. These software offer a variety of features, including real-time quotes, technical analysis tools, charts and custom alerts to meet the needs of different traders. Whether you are an experienced professional or a beginner, this article will provide you with valuable insights to help you find the best viewing software for your trading style.

See all articles