Php implements the QQ space to get the user name of the current user and generate an image

Source: Internet
Author: User
Php implements the QQ space to get the user name of the current user and generate an image

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:

  1. $ Ment = $ _ SERVER ["HTTP_REFERER"];
  2. If ($ ment = 'http: // cnc.qzs.qq.com/qzone/newblog/v5/editor.html '){
  3. Header ("HTTP/1.0 500 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, 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. ?>

Obtain the nickname through the QQ number through the requested interface:

  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. ?>

I hope this article will help you with 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.