如何使用php访问gmail收件箱feed

2024-03-29 14:18:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我有我的域名的谷歌应用帐户。谷歌应用程序文档说要使用Atom的Gmail,你必须已经有一个聚合器。我使用phpsimplepie解析应用程序上的rss和atom提要。Google文档显示url是https://mail.google.com/mail/feed/atom,然后输入你的Gmail地址和密码。在

我可以使用set the feed url设置url。我好像不明白,如何添加用户名和密码。谢谢你的帮助。谢谢

更新:-

我的一个朋友说这在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()

我对Python一无所知。我感谢任何能帮助我理解如何在php中实现类似功能的人。在

我很感激你的帮助。在


Tags: 文档httpscomauth应用程序urlfeedgoogle
1条回答
网友
1楼 · 发布于 2024-03-29 14:18:10

将CURL与CURLOPT_USERPWD选项一起使用,并获得所提到的URL的内容。在

curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);

但这只给了我未读的邮件。在

相关问题 更多 >