Ejemplo n.º 1
0
    def get(self):
        current_user = users.get_current_user()
        current_email = current_user.email()

        searchStr = self.request.get('str')
        contextIO = ContextIO(api_key=settings.CONTEXTIO_OAUTH_KEY,
                              api_secret=settings.CONTEXTIO_OAUTH_SECRET,
                              api_url=settings.CONTEXTIO_API_URL)
        response = contextIO.contactsearch(searchStr,account=current_email)
        self.response.out.write(simplejson.dumps(response.get_data()))
Ejemplo n.º 2
0
import argparse

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Python context.io wrapper")
    parser.add_argument(
        "--email_ids", dest="email_ids", type=str, default=None, help="cmail ids seperate by comma ( , )"
    )
    parser.add_argument(
        "--limit",
        dest="limit",
        type=int,
        default=3,
        help="if case it takes too long a low number here will limit the numer of emails asked for.",
    )
    args = parser.parse_args()
    api_client = ContextIO(api_key=api_key, api_secret=api_secret)
    email_ids = args.email_ids
    msg_ids = api_client.contactmessages(
        email_ids, account=mailbox_to_query, limit=args.limit
    ).get_data()  # add limit=10 iyw
    msgs = [
        striphtml(
            api_client.messagetext(account=mailbox_to_query, message_id=msg[u"emailMessageId"]).get_data()[0]["content"]
        )
        for msg in msg_ids
    ]
    print len(msgs)
    url_list = set()
    words = []
    for mail in msgs:
        for x in re.findall("http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+", mail):
Ejemplo n.º 3
0
# -*- coding: utf-8 -*-

from contextIO.ContextIO import ContextIO

api_key = 'YOUR_KEY'
api_secret = 'YOUR_SECRET'
mailbox_to_query = '*****@*****.**'

api_client = ContextIO(api_key=api_key,
                       api_secret=api_secret)

# EXAMPLE 1
# Print the subject line of the last 20 emails sent to with [email protected]
response = api_client.contactmessages(account=mailbox_to_query,to_address='*****@*****.**',limit=20)
for message in response.get_data():
    print 'Subject %s' % message['subject']


# EXAMPLE 2
# Download all versions of the last 2 attachments exchanged with [email protected]

response = api_client.contactfiles(account=mailbox_to_query,email='*****@*****.**',limit=2)
for document in response.get_data():
    print "Downloading all versions of document %s" % document['fileName']

    for attachment in document['occurences']:
        file_response = api_client.downloadfile(file_id=attachment['fileId'])
        file_content_type = file_response.get_content_type()

        fileobj = open(attachment['fileName'], mode="wb")
        fileobj.write(file_response.get_content())