【问题标题】:How to access gmail inbox feed using php如何使用 php 访问 gmail 收件箱提要
【发布时间】:2012-05-21 06:20:40
【问题描述】:

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

我可以使用设置提要 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 中实现类似功能的人。

感谢您的帮助。

【问题讨论】:

标签: php python cakephp gmail-imap simplepie


【解决方案1】:

使用带有 CURLOPT_USERPWD 选项的 CURL 并获取提到的 URL 的内容。

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

这只是给了我未读的电子邮件。

【讨论】:

    猜你喜欢
    • 2013-04-15
    • 2017-03-09
    • 2011-04-14
    • 1970-01-01
    • 1970-01-01
    • 2010-11-26
    • 2020-10-10
    • 2014-10-19
    • 2016-08-21
    相关资源
    最近更新 更多