The example in this article describes the method of using PHP to obtain the username of the current user and generate pictures in QQ space. Share it with everyone for your reference. The details are as follows:
Recently, I found that some pictures containing the current user’s nickname and QQ number are often reprinted in the space. I was very curious and studied the principle
The principle is very simple, the picture is generated using php, okay, just enter 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 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",$rr);
- imagettftext($im,26,0,87,125,$black,"./simsun.ttc",$r);
- imagejpeg($im);
- imagedestroy($im);
- ?>
-
-
Copy code
The requested interface is to obtain the nickname through 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 code
I hope this article will be helpful to everyone’s PHP programming design.
|