php - Show e-mails from Gmail inbox in SaaS website -
is there way show e-mails gmail inbox in saas website in php?
update: op edited question asking php client library.
the php gmail google client library available still in beta. code snippets on how use google api in github repository gmail api example not available. gmail api definition file place started.
you can use google gmail api. has client libraries in .net, java , python. cite docs:
your app can use api add gmail features like:
- read messages gmail
- send email messages
- modify labels applied messages , threads
- search specific messages , threads
an example on how use api per quick start guide:
#!/usr/bin/python import httplib2 apiclient.discovery import build oauth2client.client import flow_from_clientsecrets oauth2client.file import storage oauth2client.tools import run # path client_secret.json file downloaded developer console client_secret_file = 'client_secret.json' # check https://developers.google.com/gmail/api/auth/scopes available scopes oauth_scope = 'https://www.googleapis.com/auth/gmail.readonly' # location of credentials storage file storage = storage('gmail.storage') # start oauth flow retrieve credentials flow = flow_from_clientsecrets(client_secret_file, scope=oauth_scope) http = httplib2.http() # try retrieve credentials storage or run flow generate them credentials = storage.get() if credentials none or credentials.invalid: credentials = run(flow, storage, http=http) # authorize httplib2.http object our credentials http = credentials.authorize(http) # build gmail service discovery gmail_service = build('gmail', 'v1', http=http) # retrieve page of threads threads = gmail_service.users().threads().list(userid='me').execute() # print id each thread if threads['threads']: thread in threads['threads']: print 'thread id: %s' % (thread['id'])
for more details, refer quick start guide: https://developers.google.com/gmail/api/quickstart/quickstart-python
there's similar question on matter.
Comments
Post a Comment