Back to Parent

# Python Code 
# Need to download the Temboo SDK

import requests
import json
from temboo.Library.Twitter.DirectMessages import GetDirectMessages
from temboo.core.session import TembooSession
import sys
import time

while 1 == 1:

    # Create a session with your Temboo account details
    session = TembooSession("graci", "Smile_More", "7ebEYKEUR6fQOkzY2iIo4vCMtDz4XimV")

    # Instantiate the Choreo
    getDirectMessagesChoreo = GetDirectMessages(session)

    # Get an InputSet object for the Choreo
    getDirectMessagesInputs = getDirectMessagesChoreo.new_input_set()

    # Set the Choreo inputs
    getDirectMessagesInputs.set_ConsumerKey("mqhOEbt7YaouyBjrNoMrMBrBr")
    getDirectMessagesInputs.set_AccessToken("964289607532675072-qsnrH6w1Advrp1Tk8vN4ahPK5zTsPqq")
    getDirectMessagesInputs.set_ConsumerSecret("eXfFeIAc6IHy1R00xldDWDJpDZjdJKoYNxLq27E1mQ8y8mjjJm")
    getDirectMessagesInputs.set_AccessTokenSecret("cnlHD3qySKQNX2Q2O9xItaunV48IurIh4fub1gp57W8He")

    # Execute the Choreo
    getDirectMessagesResults = getDirectMessagesChoreo.execute_with_results(getDirectMessagesInputs)

    inbox = getDirectMessagesResults.get_Response()
    d = inbox.replace("false", "False")
    d = d.replace("true", "True")
    d = d.replace("null", "None")
    d = eval(d)

    num_dem = len(d)
    str(num_dem)

    # Send data to the cloud 
    requests.post('https://api.particle.io/v1/devices/events', data = {'name':'DirectMessages', 'data':str(num_dem), 'private':'true', 'ttl':60, 'access_token':'070f57a959b0b7155f81d88bf60f57122ed4dda6'})

    time.sleep( 10 )
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0