Ben içerikleri aynı modelin birçok e-posta, örneğin almak
Name: XXX
Phone: XXX
Bio: XXX
......
Ben bu e-postaları ayrıştırmak ve bir veritabanına verileri kaydetmek için bir PHP komut dosyası yazmak istiyorum. Ben bu e-postaların içeriğini almak için () file_get_contents kullanmaya çalıştı.
Sorun benim e-postalara erişmek için kimlik doğrulaması gerektiriyor olmasıdır. Ben (localhost aslında) sunucu üzerinde e-posta hesabınızda oturum olsa da, file_get_contents () hala beni oturum için ister web sayfasını geri
Peki nasıl bir PHP komut dosyası ile benim e-postaların içeriğine erişmek için?
EDIT: it is a gmail account.
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, false);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($ch, CURLOPT_URL, $gmail_url);
// not sure how to set this option
curl_setopt($ch, CURLOPT_REFERER, $login_url);
$output = curl_exec($ch);
curl_close($ch);
echo $output;