This example describes how to use php to obtain the user name of the current user and generate an image in the QQ space. Share it with you for your reference. The details are as follows: Recently, I found that some images containing the nickname and QQ number of the current user are often reprinted in the space. I am curious and have studied the principle. The principle is very simple. images are generated using php. okay, go to the code directly. Image source code:
- $ 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, 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 );
- ?>
Obtain the nickname through the QQ number through the requested interface:
- 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 ));
- ?>
I hope this article will help you with php programming. |