Last active
April 1, 2018 07:56
-
-
Save Oliviercreativ/1cb52bbc98ad4d8fd195ccff91bae270 to your computer and use it in GitHub Desktop.
Capturez et Tweetez en appuyant sur un bouton
This file contains hidden or 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 tweepy | |
import picamera | |
from time import sleep | |
import RPi.GPIO as GPIO | |
# Consumer keys and access tokens, used for OAuth | |
consumer_key = '' | |
consumer_secret = '' | |
access_token = '' | |
access_token_secret = '' | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setup(25, GPIO.IN, GPIO.PUD_UP) | |
# OAuth process, using the keys and tokens | |
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) | |
auth.set_access_token(access_token, access_token_secret) | |
# Creation of the actual interface, using authentication | |
api = tweepy.API(auth) | |
with picamera.PiCamera() as camera: | |
camera.start_preview() | |
camera.annotate_text = "TweetBox by Creativpi" | |
while True: | |
GPIO.wait_for_edge(25, GPIO.FALLING) | |
status = 'PhotoTweet from TweetBox by Creativpi.fr' | |
sleep(1) | |
camera.capture('/home/pi/image.jpg') | |
api.update_with_media('/home/pi/image.jpg', status=status) | |
camera.stop_preview() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment