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.
Currently the workflow seems to be as follows:
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.
Download emails:
From the documentation, it seems that this is the API call to show a list of messages:
GET https://www.googleapis.com/gmail/v1/users/userId/messages
My Question:
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.
I understand how to do this in Python, as per the example https://developers.google.com/gmail/api/quickstart/quickstart-python but I don't see how I'd port this code to Objective-C.
The basic workflow is correct and you have multiple ways to achieve what you want:
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.
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...
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 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.
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.
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.
You saw the python example code to retrieve a page of threads:
threads = gmail_service.users().threads().list(userId='me').execute()
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;
All actions described in the API reference are supported by Google APIs Client Library for Objective-C.
Related
The JavaScript chat client SDK is missing some functionality that the REST API has, like list users. Should the 1st person chat client be using the REST API as well to supplement gaps in the client SDK or just in general? Or is it strictly for backend management?
Twilio developer evangelist here
The Chat SDK itself doesn't give all of the same access as the REST API because that would put that access directly in the hands of all users of the Chat SDK. Restricting things like listing users of the app to the REST API means that your application has greater control over those functions and can restrict access or use it only in specific circumstances.
As we've discussed in your other question, how you actually manage things in your application, whether it is by calling to the REST API or storing data in your own user database, is up to you and depends on what will work best for your application.
I am developing one IOS Application in which i am integrate Gmail via Mailcore library, Now I want add search functionality for Inbox for which user can search their Email Subject and Body. But i am not aware how to implement it. Can anyone help me out? Is there any sample source code for this in Mailcore?
Use this it has search functionality
http://code.google.com/p/remail-iphone/
MailCore api I've developed same kind of app and have use it. They provide access to IMAP and SMTP servers.
Download from here
https://github.com/mronge/MailCore/
Could anyone please summarize the differences between Twitter's REST API and its Streaming API?
And does either of them uses Push technology?
The REST API lets you query or modify a user's account. You don't need their permission to query their account, you do need it to modify their account. They provide permission through OAuth authentication.
The streaming API delivers tweets based on search terms or for specific users you request, along with info about the author, in real-time. You do not need the tweet author's permission. You must log into some Twitter account to use streaming, using either basic or OAuth authentication.
Neither uses push, but streaming is a continuous net connection, so it is real-time delivery, making it functionally similar to push.
For anybody coming to this more recently, The REST API (v1.0) has now been retired with v1.1 being the only version. This Does now require authentication for everything, including reads.
Authentication required on all endpoints
In version 1.1, we're requiring applications to authenticate all of
their requests with OAuth 1.0a or Application-only authentication. Not
only will this visibility allow us to prevent abusive behavior, but it
will also help us to further understand how categories of applications
are using the API. We'll apply that understanding to better meet the
needs of developers as we continue to evolve the platform. At this
time, all authentication requires user context, but in the coming
weeks we'll be pushing out support for a form of authentication not
requiring a user context.
Actually you can use search through the REST API as well. For example it's the only way to combine geo AND query keyword, while the Stream API can only use OR logic.
I think it's about defacto push streaming as Adam Green has said.
Can twitter api notify my app if for example some #username gets mentioned (push like), instead of checking every
minute if a username/usernames are mentioned?
Why don't you use the Twitter Streaming APIs
The Twitter Streaming API allows
high-throughput near-realtime access
to various subsets of public and
protected Twitter data.
This is not yet supported by the API. There are 3rd-party APIs that can do this though. I used Imified before to do just this, they support Twitter mentions as well as IM networks like GTalk.
I have some PHP creating automatic Twitter updates, which in the small print at the bottom reads "[date/n minutes ago] via API".
Is it possible to somehow change the "via API" part to something more useful and descriptive?
It looks like you have to utilize OAuth authentication. As per the Twitter API Wiki:
How do I get “from [MyApp]” appended to updates sent from my API application?
We now recommend developers use OAuth to perform authentication with the API. When applications use OAuth, Twitter automatically knows the source of status updates. We are therefore able to append source attribution (from "[MyApp]") to tweets. If you would like tweets from your application to recieve a source parameter, please register an application and implement OAuth authentication. We will automatically include your application as the source for any tweets sent from your application.
We originally allowed applications to create a source paramter for non-OAuth use but that has been discontinued. Applications pre-OAuth source parameters will remain active, but new registrations are no longer accepted.