[英]How to access gmail inbox feed using php
I have google app account for my domain. 我的网域有Google应用帐户。 Google app documentation says To use Gmail with Atom, you must already have an aggregator.
Google应用程序文档说,要将Gmail与Atom一起使用,您必须已经有一个聚合器。 I use php simplepie to parse rss and atom feeds on my app.
我使用php simplepie解析我的应用程序上的rss和atom提要。 Google documentation says url is https://mail.google.com/mail/feed/atom , and enter your Gmail address and password.
Google文档说url为https://mail.google.com/mail/feed/atom ,然后输入您的Gmail地址和密码。
I can set url using Set the feed URL. 我可以使用设置供稿网址来设置网址。 I cannot seem to figure out, how to add the username and password.
我似乎无法弄清楚如何添加用户名和密码。 I appreciate any help.
感谢您的帮助。 Thanks
谢谢
UPDATE:- 更新:-
One of my friends said this works in python. 我的一位朋友说这在python中有效。
import urllib2
def get_unread_msgs(user, passwd):
auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password(
realm='New mail feed',
uri='https://mail.google.com',
user='%s@gmail.com' % user,
passwd=passwd
)
opener = urllib2.build_opener(auth_handler)
urllib2.install_opener(opener)
feed = urllib2.urlopen('https://mail.google.com/mail/feed/atom')
return feed.read()
I have no knowledge of python. 我不了解python。 I appreciate anybody who can help me understand how to implement something similar in php.
我感谢任何可以帮助我了解如何在php中实现类似功能的人。
I appreciate all your help. 感谢您的帮助。
Use CURL with the CURLOPT_USERPWD
option and get the content of the mentioned URL. 将CURL与
CURLOPT_USERPWD
选项一起使用,并获取所提及URL的内容。
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
This only gave me unread emails though. 但是,这只给了我未读的电子邮件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.