Skip to content

Instantly share code, notes, and snippets.

@k3174r0
Last active May 21, 2018 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k3174r0/c477f67f92ca5c8ed950bce7372c8203 to your computer and use it in GitHub Desktop.
Save k3174r0/c477f67f92ca5c8ed950bce7372c8203 to your computer and use it in GitHub Desktop.
import requests
import json
import tweepy
#TwitterAPI Settings
CONSUMER_KEY = ""
CONSUMER_SECRET = ""
ACCESS_TOKEN = ""
ACCESS_TOKEN_SECRET = ""
#littleBits(cloudbBits) Settings
DEVICE_ID = ""
CLOUDBITS_ACCESS_TOKEN = ""
url = "https://api-http.littlebitscloud.cc/v2/devices/" + DEVICE_ID + "/output"
headers = {"Authorization": "Bearer " + CLOUDBITS_ACCESS_TOKEN, "Content-type": "application/json"}
payload = { "percent": 100, "duration_ms": 3000 }
class MyStreamListener(tweepy.StreamListener):
def on_status(self, status):
# print(status.text)
pass
def on_event(self, event):
if event.event == "favorite":
print("favorite")
r = requests.post(url, data=json.dumps(payload) ,headers=headers)
print(r)
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
api = tweepy.API(auth)
myStreamListener = MyStreamListener()
myStream = tweepy.Stream(auth = api.auth, listener=myStreamListener)
myStream.userstream()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment