Twitter Messaging + Raspberry Pi
Jump to navigation
Jump to search
- Create a Twitter account
- Go to apps.twitter.com/ and click create new app button
- Complete application details form (Enter name, description, and publicly accessible website)
- Modify your app permissions from read only to read and write
- Click the "keys" and "access tokens" tab
- Create an "access token"
- Refresh page and copy each of your "access tokens" (Consumer Key, Consumer Secret, Access Token, Access Token Secret)
- Make sure your date and time are correct using the raspberry Pi configuration tool
- Open Terminal and Download Twython type: sudo apt-get install Twython --upgrade
- Connect to Twitter API using the keys, refer to Figure 12.1
- Save a picture onto Raspberry Pi
- If you want a message in your picture type: POST_MESSAGES = [ "Peek-A-Thief is awesome" , "I am a WashU engineer" , "I am not in the artsci department"]
- To randomize the message that appears with the photo type: postmsg = choice(POST_MESSAGES)
- To post a picture type: t.update_status_with_media(status = POST_MESSAGES, media=photo)