search
HomeBackend DevelopmentPHP TutorialPHP simulates login to QQ mailbox (detailed explanation of curl command)

  1. header("Content-type:text/html;charset=utf-8");

  2. $cookie_file = dirname(__FILE__)."/cookie_".md5( basename(__FILE__)).".txt"; //Set the cookie file saving path and file name
  3. function vlogin($url,$data){ //Simulate login to obtain the Cookie function
  4. $curl = curl_init(); // Start A CURL session
  5. curl_setopt($curl, CURLOPT_URL, $url); // The address to be accessed
  6. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // Check the source of the authentication certificate
  7. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1) ; // Check whether the SSL encryption algorithm exists from the certificate
  8. curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // Simulate the browser used by the user
  9. curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // Use automatic redirect
  10. curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // Automatically set Referer
  11. curl_setopt($curl, CURLOPT_POST, 1); // Send a regular Post request
  12. curl_setopt($curl, CURLOPT_POSTFIELDS, $data) ; // The packet submitted by Post
  13. curl_setopt($curl, CURLOPT_COOKIEJAR, $GLOBALS['cookie_file']); // The name of the file that stores Cookie information
  14. curl_setopt($curl, CURLOPT_COOKIEFILE, $GLOBALS['cookie_file']); // Read the cookie information stored above
  15. curl_setopt($curl, CURLOPT_TIMEOUT, 30); // Set timeout limit to prevent endless loops
  16. curl_setopt($curl, CURLOPT_HEADER, 0); // Display the content of the returned Header area
  17. curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1); // The obtained information is returned in the form of a file stream
  18. $tmpInfo = curl_exec($curl); // Execute the operation
  19. if (curl_errno($curl)) {
  20. echo 'Errno'. curl_error($curl);
  21. }
  22. curl_close($curl); // Close the CURL session
  23. return $tmpInfo; // Return data
  24. }
  25. function vget($url){ // Simulate the function of getting content
  26. $curl = curl_init(); // Start a CURL session
  27. curl_setopt($curl, CURLOPT_URL, $url); // The address to be accessed
  28. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // Check the source of the authentication certificate
  29. curl_setopt( $curl, CURLOPT_SSL_VERIFYHOST, 1); // Check whether the SSL encryption algorithm exists from the certificate
  30. curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // Simulate the browser used by the user
  31. curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // Use automatic redirect
  32. curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // Automatically set Referer
  33. curl_setopt($curl, CURLOPT_HTTPGET, 1); // Send a regular Post request
  34. curl_setopt($ curl, CURLOPT_COOKIEFILE, $GLOBALS['cookie_file']); // Read the cookie information stored above
  35. curl_setopt($curl, CURLOPT_TIMEOUT, 30); // Set timeout limit to prevent infinite loop
  36. curl_setopt($curl, CURLOPT_HEADER, 0); // Display the content of the returned Header area
  37. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // The obtained information is returned in the form of a file stream
  38. $tmpInfo = curl_exec($curl); // Execute the operation
  39. if ( curl_errno($curl)) {
  40. echo 'Errno'.curl_error($curl);
  41. }
  42. curl_close($curl); // Close CURL session
  43. return $tmpInfo; // Return data
  44. }
  45. function vpost($ url,$data){ // Simulate the submit data function
  46. $curl = curl_init(); // Start a CURL session
  47. curl_setopt($curl, CURLOPT_URL, $url); // The address to be accessed
  48. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // Check the source of the authentication certificate
  49. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1); // Check whether the SSL encryption algorithm exists from the certificate
  50. curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] ); // Simulate the browser used by the user
  51. curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // Use automatic jump
  52. curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // Automatically set the Referer
  53. curl_setopt($curl, CURLOPT_POST , 1); // Send a regular Post request
  54. curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post submitted data packet
  55. curl_setopt($curl, CURLOPT_COOKIEFILE, $GLOBALS['cookie_file']); // Read the cookie information stored above
  56. curl_setopt($curl, CURLOPT_TIMEOUT, 30); // Set timeout limit to prevent infinite loop
  57. curl_setopt($curl, CURLOPT_HEADER, 0); // Display the content of the returned Header area
  58. curl_setopt($ curl, CURLOPT_RETURNTRANSFER, 1); // The obtained information is returned in the form of a file stream
  59. $tmpInfo = curl_exec($curl); // Execute the operation
  60. if (curl_errno($curl)) {
  61. echo 'Errno'.curl_error( $curl);
  62. }
  63. curl_close($curl); // Key CURL session
  64. return $tmpInfo; // Return data
  65. }
  66. function delcookie($cookie_file){ // Delete Cookie Function

  67. @unlink($cookie_file); // Execute deletion
  68. }
  69. function readcookies( $file)

  70. {
  71. $result = null;
  72. $fp = fopen( $file, "r" );
  73. if($fp)
  74. {
  75. while ( !feof( $fp ) )
  76. {
  77. $buffer = fgets( $fp, 4096 );
  78. $result = $buffer;
  79. //$tmp = @split( "/t", $buffer );
  80. //$ result[@trim( $tmp[5] )] = @trim( $tmp[6] );
  81. }
  82. fclose($fp);
  83. }
  84. return $result;
  85. }
  86. $url = 'http: //w.mail.qq.com/cgi-bin/loginpage?f=xhtml';
  87. if(!file_exists($cookie_file)) { // Check whether the cookie exists
  88. $str = vget($url); // Get the submission background
  89. preg_match("/action="([^"]*?)"/isU",$str,$hash); // Extract the login random value
  90. print_r($hash[1]);
  91. vlogin( $hash[1],'&f=xhtml&uin=your qq number&aliastype=@qq.com&pwd=qq number password&mss=1'); // Log in to get Cookie
  92. }

  93. else
  94. {
  95. vget("http://w30.mail.qq.com/cgi-bin/today?sid=ggQq2H-cUHdDdHs0z6rT6vN8,4,z-yTNgDwU&first=1");
  96. echo 'Cookie generated';
  97. }
  98. ? >
Copy code

>>> For more articles about php simulated login, please refer to the topic link: php simulated login php curl simulated login tutorial collection



Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
11 Best PHP URL Shortener Scripts (Free and Premium)11 Best PHP URL Shortener Scripts (Free and Premium)Mar 03, 2025 am 10:49 AM

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Introduction to the Instagram APIIntroduction to the Instagram APIMar 02, 2025 am 09:32 AM

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Working with Flash Session Data in LaravelWorking with Flash Session Data in LaravelMar 12, 2025 pm 05:08 PM

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

Build a React App With a Laravel Back End: Part 2, ReactBuild a React App With a Laravel Back End: Part 2, ReactMar 04, 2025 am 09:33 AM

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Simplified HTTP Response Mocking in Laravel TestsSimplified HTTP Response Mocking in Laravel TestsMar 12, 2025 pm 05:09 PM

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

cURL in PHP: How to Use the PHP cURL Extension in REST APIscURL in PHP: How to Use the PHP cURL Extension in REST APIsMar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

12 Best PHP Chat Scripts on CodeCanyon12 Best PHP Chat Scripts on CodeCanyonMar 13, 2025 pm 12:08 PM

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Announcement of 2025 PHP Situation SurveyAnnouncement of 2025 PHP Situation SurveyMar 03, 2025 pm 04:20 PM

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),