TeCoEd (Teaching Computing Education)
  • Home
    • Freelance
    • Book
    • Downloading
  • Python
    • Learn Python >
      • Python Modules
    • Python Programs >
      • Higher or Lower
      • Magic Calculator
      • Password Checker
      • Python Pit
    • What's News App
    • Pixels to Cells
    • Python Mosaics
    • Python OCR
    • L-1-AM
    • Web Scraping >
      • Scraping Trains
    • Weather App
    • Snakes and Windows
    • Python Web Server >
      • Flask
    • Python Picks
  • Raspberry Pi
    • All About the Pi
    • Getting Started
    • Remote Desktop and VNC
    • Static IP Address
    • Sonic Pi >
      • 3.14
    • Twitter Feed >
      • Tweepy
    • Android & Pi >
      • Advanced Apps
      • Odds
    • A.I on the the Pi
    • CRON
    • Pick Your Own
  • Pi Hardware
    • Pi HATS >
      • Sense Hat Hacks
      • AstroPi HAT
      • Unicorn-HAT >
        • Unicorn Alphabet Disco
        • Uni Codes / Programs
      • Skywriter
      • Piano HAT
    • STS Pi
    • Pi Camera >
      • Pi-Cam, Python & Email >
        • Time Lapse
      • Pi Noir
    • Pipsta >
      • Flask, Input & Printers
    • Raspberry Pi Power >
      • Energenie IR power
    • Pibrella
    • Distance Sensor
    • LCD Screen
    • Pi-Tooth
    • Robot Arm
    • PiGlow
    • PiFM
    • Accelerometer
    • PiFace >
      • Installing PiFace >
        • Python Commands
  • Pi-Hacks
    • Drone Hacks
    • Pi Glue Gun Hack
    • Blinkt!
    • Sonic Pixels
    • R2D2
    • Get to the chopper
    • Astro Bird
    • Twitter Translator
    • Hacking a Robot
    • Nature_Box >
      • Best Nature Photos
    • Wearable Tech >
      • Project New York
      • P.N.Y Part 2 Health
      • P.N.Y Part 3 Games
      • P.N.Y Part 4 Translation
    • Dino-Tweet
    • Other Links
  • Pi-Hacks 2
    • The Joker
    • Hologram Machine
    • Google Vision: Camera Tell
    • Yoda Tweets
    • Pi Phone
    • Darth Beats
    • Twitter Keyword Finder
    • Crimbo Lights Hack
    • Xmas Elf
    • Halloween 2016
    • Halloween Hack 2015
    • Socrative Zombie
    • Voice Translation
    • The Blue-Who Finder
    • GPIO, Twitter
    • Pi Chat Bot >
      • Dictionary Definitions
    • PiGlow & Email
    • Pibrella Alarm System
    • SMS with Python >
      • Spooking a Mobile
  • Pi-Hacks 3
    • Night Vision
    • Enviro+ Weather
  • Minecraft
    • Minecraft API
    • Minecraft Sweeper
    • PiGlove: Minecraft Power Up
    • Minecraft Photo-booth
    • Rendering Pixels
    • Speed Cube
    • Lucky Dip
  • Computing
    • Why Computing?
    • Can You Compute
    • micro:bit
    • Coding Resources
    • Learn to Code >
      • Coding with iPads
      • Apps Creation Tools
      • sKratchInn
      • Sound Editing
    • Cheat Sheets
    • Theory
    • HOUR OF CODING
    • BEBRAS Computing Challange
    • Computer Facts
    • Free Software and Links
  • Contact Me

Getting Started?


This is an ALTERNATIVE module to use instead of Twython.  It is still simple to install and I found that it overcome some of the streaming issues I was encountering when trying to print my Tweets / messages.
As before you require a token, go to the Twitter API site and register your details.  This is required to create the Authentication Token and Access Token.  
Once you have created your own account and you have the authorisation codes and tokens the program can be created.

First Update the Raspberry Pi
sudo apt-get update 

Upgrade your Pi
sudo apt-get upgrade 

Next install the python setup tools and pip, use this to install the Twython module that will allow the communication between the twitter API and Python.
sudo apt-get install python-setuptools 
sudo easy_install tweepy
or
sudo pip install tweepy

Using Tweepy


The code is very similar to the Twython methods however at present the public timeline is not working.  Further documentation can be found here.

Streaming your Timeline


You own Tweets / timeline can be stream using the simple api.user_timeline() this returns a few of  your most recent posts to twitter. 
Your Tweets
File Size: 0 kb
File Type: py
Download File


Getting your Mentions /  Notifications


This simple code api.mentions_timeline() returns the contents of your notifications / mentions.  It does not return new followers only messages in which your Twitter ID is mentioned.
Your Mentions
File Size: 0 kb
File Type: py
Download File

The Twitter-Bot


Combining the Tweepy code and the Talking Pi code at here, you can create a very simple Twitter Bot that reads out or speaks your timeline or your mentions from your timeline.  Code and example are shared below, just add your own Tokens.
Your Timeline
File Size: 1 kb
File Type: py
Download File

Your Mentions
File Size: 1 kb
File Type: py
Download File


Getting Twitter Users Data


A simple variation of the basic code that searches for a Twitter Users ID and then returns the number of Followers, Mentions, Tweets etc.   The program enables you to enter in a users ID and then it returns their data.
User ID Data
File Size: 1 kb
File Type: py
Download File