Last active
May 21, 2018 08:24
-
-
Save k3174r0/c477f67f92ca5c8ed950bce7372c8203 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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