Prima pagină > Unelte SEO in PHP > Citire GMAIL fara IMAP cu PHP

Citire GMAIL fara IMAP cu PHP

Iata o metoda cum poti detecta prin PHP daca ai mesaje necitite in mailboxul de la GMAIL.
Cum observati aceasta metoda nu necesita IMAP.


<?php
$username = "myuser";
$password = "mypass";

// Initialise cURL
$c = curl_init('https://gmail.google.com/gmail/feed/atom');

$headers = array(
 "Host: gmail.google.com",
 "Authorization: Basic ".base64_encode($username.':'.$password),
 "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4",
 "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5",
 "Accept-Language: en-gb,en;q=0.5",
 "Accept-Encoding: text",
 "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7",
 "Date: ".date(DATE_RFC822)
);

curl_setopt($c, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($c, CURLOPT_COOKIESESSION, true);
curl_setopt($c, CURLOPT_HTTPHEADER, $headers);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($c, CURLOPT_UNRESTRICTED_AUTH, 1);
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 1);


$str = curl_exec($c);
echo $str;

curl_close($c);
?>

Anunțuri
  1. Niciun comentariu până acum.
  1. No trackbacks yet.

Lasă un răspuns

Completează mai jos detaliile tale sau dă clic pe un icon pentru a te autentifica:

Logo WordPress.com

Comentezi folosind contul tău WordPress.com. Dezautentificare / Schimbă )

Poză Twitter

Comentezi folosind contul tău Twitter. Dezautentificare / Schimbă )

Fotografie Facebook

Comentezi folosind contul tău Facebook. Dezautentificare / Schimbă )

Fotografie Google+

Comentezi folosind contul tău Google+. Dezautentificare / Schimbă )

Conectare la %s

%d blogeri au apreciat asta: