I want to get the contents of some emails in my Gmail account. I want to use PHP curl extensions to do this. I followed these steps in my first attempt:
- In PHP code, the output of the content.
- In the browser, to login the user input username and password.
- In PHP code, save cookies in a file named cookie.
- In PHP code, request with cookies recovered from cookie.txt and output the content.
The following code does not work:
$ login_url = 'https://www.google.com/accounts/ServiceLoginAuth'; $ Gmail_url = 'https://mail.google.com/'; $ Cookie_file = dirname (__ file__). '/cookie.txt'; $ Ch = curl_init (); Curl_setopt ($ CH, CURLOPT_SSL_VERIFYPEER, incorrect); Curl_setopt ($ CH, CURLOPT_HEADER, incorrect); Curl_setopt ($ ch, CURLOPT_POST, true); Curl_setopt ($ CH, CURLOPT_RETURNTRANSFER, true); Curl_setopt ($ CH, CURLOPT_FOLLOWLOCATION, true); Curl_setopt ($ CH, CURLOPT_COOKIEJAR, $ cookie_file); Curl_setopt ($ CH, CURLOPT_URL, $ login_url); $ Output = curl_xac ($ CH); $ Echo output; Curl_setopt ($ ch, CURLOPT_URL, $ gmail_url); Curl_setopt ($ CH, CURLOPT_COOKIEFILE, $ cookie_file); $ Output = curl_xac ($ CH); $ Echo output; Curl_close ($ ch);
Your viewpoint is incorrect Your content can not be retrieved and it outputs , The user is expected to fill the details and press Enter. Since the form is
& lt; Form action = "https://www.google.com/accounts/ServiceLoginAuth" method = "post" & gt; Is defined as
Login details will be submitted by the browser on that page and your script will never receive cookies. You must submit a post request for Already with a username and password . Only then will the curl get a reaction with the cookies.
He said, I had suggested that you scour all this, enable IMAP in GMM and use it to access your e-mail.
div>
Comments
Post a Comment