php实现QQ空间获取当前用户的用户名并生成图片,
本文实例讲述了php实现QQ空间获取当前用户的用户名并生成图片的方法。分享给大家供大家参考。具体如下:
最近发现空间里经常会转载一些含有当前用户昵称和qq号的图片,很好奇,研究了一下原理
原理很简单,图片是利用php生成的,好吧,直接上代码
图片源代码:
<?php $ment = $_SERVER["HTTP_REFERER"]; if($ment == 'http://cnc.qzs.qq.com/qzone/newblog/v5/editor.html'){ header("HTTP/1.0 500 Internal Server Error"); exit;} preg_match("#[0-9]{5,11}#",$ment,$rr); $r=$rr[0]; $webtext=file_get_contents('http://www.phperzone.cn/demo/qqinfo-service.php?qq='.$r); preg_match('#"nickname":"(.*?)"#',$webtext,$rr); $rrr=$rr[1]; ob_clean(); header("Content-type:image/png"); $im=imagecreatefromjpeg("1.jpg"); $black = ImageColorAllocate($im, 56,73,136); $rrr = mb_convert_encoding($rrr, "utf-8","UTF-8"); imagettftext($im,20,0,90,68,$black,"./simsun.ttc",$rrr); imagettftext($im,26,0,87,125,$black,"./simsun.ttc",$r); imagejpeg($im); imagedestroy($im); ?>
请求的接口获取通过qq号获取昵称:
<?php header("Content-Type:text/html;charset=utf-8"); $qq = $_GET ["qq"]; echo htmlspecialchars(file_get_contents('http://r.qzone.qq.com/cgi-bin/user/cgi_personal_card'. "?uin=" . $qq)); ?>
希望本文所述对大家的php程序设计有所帮助。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Linux new version
SublimeText3 Linux latest version

Zend Studio 13.0.1
Powerful PHP integrated development environment