Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where and how can I install twitter's Python API?

Tags:

twitter

api

I went to twitter's API, it redirected me to google code, and the website wasn't there. Any alternative twitter APIs, plus tutorials? thanks!

like image 589
Matt Bettinson Avatar asked Dec 22 '22 14:12

Matt Bettinson


2 Answers

Try Tweepy: http://code.google.com/p/tweepy/

You can get to a tutorial wiki page for it at the same Google Code link.

To install it with easy_install, just run easy_install tweepy

To install it with git:

git clone git://github.com/joshthecoder/tweepy.git
cd tweepy
python setup.py install

To install it from source, download the source from http://pypi.python.org/pypi/tweepy then run something like:

tar xzvf tweepy-1.7.1.tar.gz
cd tweepy-1.7.1
python setup.py install
like image 63
146 Avatar answered Feb 04 '23 08:02

146


I've been using Python-Twitter for the past couple of months. It makes it extremely easy to pull data from the Twitter API as well as post Tweets.

You can install via pip:

pip install python-twitter

or by cloning from git => https://github.com/bear/python-twitter.git then installing the dependencies (which can be done via pip) follow the instructions in README.rt

python setup.py build

then

python setup.py install

After you've installed the library, I'd recommend setting up a simple authentication file (eg. twitterAuth.py) like this one:

# twitterAuth.py

import twitter

"""This script is meant to connect to the Twitter API via the tokens below"""

api = twitter.Api(consumer_key='yourConsumerKeyGoesHere',
    consumer_secret='yourConsumerSecretGoesHere',
    access_token_key='your-AccessTokenGoesHere',
    access_token_secret='yourTokenSecretGoesHere')

Then you can simply import this from any scripts that need to acccess the Twitter API. Here's a simple example that posts a Tweet:

from twitter import * 
import twitterAuth

api = twitterAuth.api

status = api.PostUpdate('testing twitter-python')
print status.text
like image 24
Joe Fusaro Avatar answered Feb 04 '23 09:02

Joe Fusaro