PHP implementation of the QQ space to get the user name of the current user and generate pictures

Source: Internet
Author: User
Tags php programming

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:

    1. $ment = $_server["Http_referer"];
    2. if ($ment = = ' http://cnc.qzs.qq.com/qzone/newblog/v5/editor.html ') {
    3. Header ("http/1.0 Internal Server Error");
    4. Exit;}
    5. Preg_match ("#[0-9]{5,11}#", $ment, $RR);
    6. $r = $RR [0];
    7. $webtext =file_get_contents (' http://www.phperzone.cn/demo/qqinfo-service.php?qq= ' $r);
    8. Preg_match (' # ' nickname ":" (. *?) " # ', $webtext, $RR);
    9. $rrr = $RR [1];
    10. Ob_clean ();
    11. Header ("Content-type:image/png");
    12. $im =imagecreatefromjpeg ("1.jpg");
    13. $black = Imagecolorallocate ($im, 56,73,136);
    14. $rrr = mb_convert_encoding ($rrr, "Utf-8", "UTF-8");
    15. Imagettftext ($im, 20,0,90,68, $black, "./SIMSUN.TTC", $rrr);
    16. Imagettftext ($im, 26,0,87,125, $black, "./SIMSUN.TTC", $r);
    17. Imagejpeg ($im);
    18. Imagedestroy ($im);
    19. ?>
Copy Code

The requested interface gets the nickname via the QQ number:

    1. Header ("Content-type:text/html;charset=utf-8");
    2. $QQ = $_get ["QQ"];
    3. Echo htmlspecialchars (file_get_contents (' Http://r.qzone.qq.com/cgi-bin/user/cgi_personal_card '). "? uin=". $QQ));
    4. ?>
Copy Code

I hope this article is helpful to everyone's PHP programming.

Php
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.