Skip to content

hacklabes/HackNights_Python_Twitter_API

Repository files navigation

HackNights Python the Twitter API

Starting Installing / Checking your python environment

Check if you have python installed

Mac/Linux

  1. Go to your terminal emulator
  2. Type python --version and pip --version
  3. If it doens't work you may need to install it

Windows

  1. You can use your PowerShell, cmd.exe or install babun, gow
  2. type python -V

Instaling Python

The easiest is downloading the packages from Python website then Setuptools

Text Editor

Sublime Brackets

Other resources

Online Python

Ipython Notebook

Online learning

Python and Twitter

Python Library

Install the library TwitterAPI there are many others if you want to have a try.

On your command line tool / terminal type

pip install TwitterAPI

Twitter API Keys

In order to access Twitter through our Python scripts it's necessary to request access and adquire four different keys.

  1. You need a Twitter account www.twitter.com
  2. Create a new application https://apps.twitter.com/app/new at the Website field you can put any website starting with http and you can let the field Callback URL empty
  3. Then go to https://apps.twitter.com/
  4. Click on your App then click in the tab Keys and Access Tokens
  5. In the bottom of the page click on generate Access Token, copy the follow keys
consumer_key = ""
consumer_secret = ""
access_token_key = ""
access_token_secret = ""

if you want to explore the API through the API console https://dev.twitter.com/rest/tools/console

  1. Download the zip file from this repo

  2. Edit the file keys.py and insert your keys between quotes "" for each variable

  3. Edit the file twitter_0_Simple_Post.py and edit the message you want to tweet.

  4. To run your script go to your command line tool /terminal

  5. Go to the folder where are all the .py files are then type

python twitter_0_Simple_Post.py

you may get a number as output, if it is 200 Sucess otherwise have a look at the error response codes from twitter

  1. Try the other scripts .py following these instructions

About

Experiments with python and Twitter API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages