In this paper, we describe the method that PHP realizes the user name of the current user and generates a picture in QQ space. Share to everyone for your reference. Specific as follows: Recently found in the space is often reproduced some contain the current user nickname and QQ number of pictures, very curious, studied the principle The principle is simple, the image is generated using PHP, OK, directly on the code Image source code:
- $ment = $_server["Http_referer"];
- if ($ment = = ' http://cnc.qzs.qq.com/qzone/newblog/v5/editor.html ') {
- Header ("http/1.0 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);
- ?>
Copy CodeThe requested interface gets the nickname via the QQ number:
- 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));
- ?>
Copy CodeI hope this article is helpful to everyone's PHP programming. |