• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

Gmail的API和iOS - 让电子邮件

用户头像
it1352
帮助1

问题说明

我想了解 Gmail的API是如何工作的。我的目标是获取所有用户在他们的收件箱邮件列表,下载到的NSArray

I'm trying to understand how the Gmail API works. My goal is to retrieve a list of all of a user's emails in their inbox, downloaded to an NSArray.

目前工作流似乎如下:

  1. 我的授权使用OAuth 2.0 iOS应用使用框架由谷歌提供。我的完成这一步,我的应用程序可以成功授权的Gmail帐户。

  1. Authorize my iOS app with OAuth 2.0 using the frameworks provided by Google. I have completed this step and my app can successfully authorize a gmail account.

下载电子邮件:

文档,似乎这在API调用来显示消息的列表:

From the documentation, it seems that this is the API call to show a list of messages:

https://www.谷歌apis.com/gmail/v1/users /用户名/邮件

我的问题:

请问我需要写我自己的Objective-C的包装,使这个API调用来下载邮件,还是会像 MailCore 让我更轻松地做到这一点?据我了解,这个API是取代IMAP的,这是 MailCore 工具。

Would I need to write my own Objective-C wrapper to make this API call to download the messages, or would something like MailCore allow me to do this more easily? As I understand it, this API is in replace of IMAP, which is what MailCore implements.

我知道如何做到这一点在Python,按照这个例子的https:/ /developers.谷歌.com/gmail/api/quickstart/quickstart-python 但我不看我怎么倒是这个端口code到Objective-C。

I understand how to do this in Python, as per the example https://developers.谷歌.com/gmail/api/quickstart/quickstart-python but I don't see how I'd port this code to Objective-C.

正确答案

#1

的基本工作流程是正确的,你有多种方式来实现你想要的:

The basic workflow is correct and you have multiple ways to achieve what you want:

  1. Gmail的API 这是一个可以用来访问Gmail邮箱,邮件发送一个RESTful API。该API支持多种可通过喜欢阅读,撰写和发送邮件Gmail的用户界面的基本操作。它也可以让你的线程和消息,并查询特定的消息和线程管理标签。

  1. The Gmail API which is a RESTful API that can be used to access Gmail mailboxes and send mail. The API supports many of the basic operations available through the Gmail user interface like reading, composing, and sending mail. It also lets you manage labels on threads and messages and query for specific messages and threads.

  • 您可以写周围的API自己的Objective-C包装作出正确的HTTP请求中的参考但它是一个大量的工作,你必须写你需要的一切,错误管理,验证,等等...

  • You can write your own Objective-C wrapper around the API to make the correct HTTP request to the differents endpoints described in the API reference but it's a lot of work, you have to write everything you need, error management, validation, etc...

您可以使用谷歌API客户端库的Objective-C 推荐的用于访问iOS和Mac OS X的应用程序基于JSON的谷歌的API。这个API还包含了许多谷歌产品,包括Gmail的支持。

You can use the Google APIs Client Library for Objective-C recommended for accessing JSON-based Google APIs for iOS and Mac OS X applications. This API include support for many Google products including Gmail.

IMAP和SMTP 协议都支持Gmail和包括的OAuth 2.0授权。

IMAP and SMTP protocols are supported by Gmail and include OAuth 2.0 authorization.

 

  • You can use any existing IMAP and SMTP libraries which supports SASL you want and should be compatible with the SASL XOAUTH2 mechanism supported by Gmail. You can use MailCore for example like you suggested.

在我看来,你正在寻找与Gmail信箱互动使Gmail的API是授权访问用户的Gmail数据的最佳选择,最简单的方法。


It seems to me you're looking for the easiest way to interact with Gmail mailboxes so the Gmail API is the best choice for authorized access to a user's Gmail data.

我会去的谷歌API客户端库Objective-C的所以你不会有写周围的API自己的包装,并可以用它的开箱。

I would go for the Google APIs Client Library for Objective-C so you won't have to write your own wrapper around the API and can use it out of the box.

您看到蟒蛇例如code检索线程的页面:

You saw the python example code to retrieve a page of threads:

threads = gmail_service.users().threads().list(userId='me').execute()

借助谷歌API客户端库Objective-C的会给你的方法做同样的事情就像可能性,包括垃圾邮件和放多个选项;在结果垃圾文件夹,结果的最大数,搜索匹配特定的查询,等一个线程。

The Google APIs Client Library for Objective-C will give you methods to do the same thing with multiple options like possibility to include the spam & trash folder in results, maximum number of results, search for a thread matching a specific query, etc.

  (id)queryForUsersThreadsList;

是由谷歌API客户端库Objective-C的支持在 API参考描述的所有动作。

All actions described in the API reference are supported by Google APIs Client Library for Objective-C.

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcgiiab
系列文章
更多 icon
同类精品
更多 icon
继续加载