Vous pouvez enrouler votre flux rss de gmail/xml avec cette fonction
function check_email($username, $password)
{
//url to connect to
$url = "https://mail.google.com/mail/feed/atom";
// sendRequest
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_ENCODING, "");
$curlData = curl_exec($curl);
curl_close($curl);
//returning retrieved feed
return $curlData;
}
Ensuite, vous pouvez renvoyer vos données soit en extraire les valeurs du xml ..
$em = "[email protected]";
$pw = "yourpassword";
$feed = check_email($em, $pw);
$x = new SimpleXmlElement($feed);
echo "<ul>";
foreach($x->entry as $msg){
$href = $msg->link->attributes()->href;
$qmark = strpos($href,"?")+1;
$qstring = substr($href,$qmark);
echo "<li><a href=\"step2.php?".$qstring."\">".$msg->title."</a><br />".$msg->summary."</li>";
}
echo "</ul>";
Ou par juste regarder l'alimentation , en fonction de ce que vous voulez faire avec elle ..
$em = "[email protected]";
$pw = "yourpassword";
$feed = check_email($em, $pw);
echo $feed;
Bon point, et je suis d'accord c'est une bonne solution. J'ai trouvé que je devais faire -k pour désactiver la vérification de cert. Je me suis trompé. – kvista
pouvez-vous obtenir le sujet avec cela? pas seulement le titre de l'email non lu? – shreddish