1
我一直在尋找這個答案的一整天。有大量的信息登錄到Gmail和顯示收件箱和獲取聯繫人等,但我無法弄清楚如何獲得電子郵件本身變成一個變量,所以我可以用PHP做它的東西。通過cURL(PHP)獲取Gmail郵件
這是我有:
function inbox($username, $password){
$url = "https://mail.google.com/mail/feed/atom";
$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);
return $curlData;
}
//calling the function
$em = "[email protected]";
$pw = "pass";
$feed = inbox($em, $pw);
$x = new SimpleXmlElement($feed);
echo "<ul>";
foreach($x->entry as $msg){
//extracting the link to the message from xml
$href = $msg->link->attributes()->href;
//create a link to the message and display title, summary
echo "<li><a href=\"".$href."\">".$msg->title."</a><br />".$msg->summary."</li>";
}
echo "</ul>";
現在,當我點擊我剛剛創建的,它只是在Gmail打開郵件中的鏈接。我想在字符串/變量中訪問消息的html。我嘗試了各種各樣的東西。我嘗試將消息鏈接轉發到另一個頁面以打開curl,但不是向我顯示消息google發送一些html與消息的另一個鏈接。如果鏈接在瀏覽器中再次點擊,則會在Gmail中打開,但如果我嘗試第三次捲曲到此鏈接,則會顯示一個空白頁。
我希望這是有道理的。要點是,我的工作服務器沒有啓用imap/pop,cURL是我知道的最後一個可以實現這一點的想法。任何想法,不勝感激。