Coder Social home page Coder Social logo

python-twitter-examples's Introduction

Python Twitter Examples

A set of Python scripts to demonstrate interactions with the Twitter API via the Python Twitter Tools module.

Usage

These examples require Python 3. To install prerequisites:

pip install -r requirements.txt

You will need to authenticate with Twitter to use these scripts. To do so, sign up for developer credentials:

https://apps.twitter.com/

You can create access credentials directly through Twitter's web interface, authorized under the username you used to create the app.

If you want your application to act on behalf of other users (for example, to post on behalf of several usernames), you'll need to authorize each separately. To be guided through this process, run:

python twitter-authorize.py

Then add your consumer and access tokens to config.py.

History

This collection was first developed for a 2012 laboratory in social data mining for the MA/MSc Digital Sociology, Digital Journalism and Creating Social Media courses at the Centre for Creative and Social Technology, Goldsmiths, University of London.

Daniel Jones <[email protected]>
http://www.erase.net

python-twitter-examples's People

Contributors

dfzunigah avatar ideoforms avatar ironchicken avatar platonbjs avatar the4rchangel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-twitter-examples's Issues

Rate Limit Handle

Hello Everyone,

I read the twitter Rest api documentation of the maximum api request in 15 min window.
What i would like to know is how to spot the rate limit at first. and how to prevent it later on by using time.sleep method perhaps or something similar

Thanks in advance!

Cannot find module 'twitter'

Hi, I wanted to execute the twitter-search-geo.py file but I get an error which says 'no module named twitter' even though I have the twitter module in my Scripts directory. I'm using Spyder 3.3.1 on Windows 10. Any help would be appreciated, thanks.

twitter-friends.py

hi. when i execute twitter-friends.py i am getting as 1043 friends. but my account is a relatively new account. what does friends mean?. i have just one follower.

and i get this after running it.
Traceback (most recent call last):
File "twitter-friends.py", line 17, in
exec("config.py", config)
File "", line 1, in
NameError: name 'config' is not defined
hduser@localhost:$ vi twitter-friends.py
hduser@localhost:
$ python twitter-friends.py
Traceback (most recent call last):
File "twitter-friends.py", line 18, in
exec("config.py".read(), config)
AttributeError: 'str' object has no attribute 'read'
hduser@localhost:$ vi twitter-friends.py
hduser@localhost:
$ python twitter-friends.py
found 1043 friends
Traceback (most recent call last):
File "/home/hduser/anaconda3/lib/python3.6/site-packages/twitter/api.py", line 319, in _handle_response
handle = urllib_request.urlopen(req, **kwargs)
File "/home/hduser/anaconda3/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/home/hduser/anaconda3/lib/python3.6/urllib/request.py", line 532, in open
response = meth(req, response)
File "/home/hduser/anaconda3/lib/python3.6/urllib/request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "/home/hduser/anaconda3/lib/python3.6/urllib/request.py", line 570, in error
return self._call_chain(*args)
File "/home/hduser/anaconda3/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/home/hduser/anaconda3/lib/python3.6/urllib/request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "twitter-friends.py", line 62, in
subquery = twitter.users.lookup(user_id = ids)
File "/home/hduser/anaconda3/lib/python3.6/site-packages/twitter/api.py", line 312, in call
return self._handle_response(req, uri, arg_data, _timeout)
File "/home/hduser/anaconda3/lib/python3.6/site-packages/twitter/api.py", line 345, in _handle_response
raise TwitterHTTPError(e, uri, self.format, arg_data)
twitter.api.TwitterHTTPError: Twitter sent status 403 for URL: 1.1/users/lookup.json using parameters: (oauth_consumer_key=9BPT2QqaGyV9ZvSGwjhVMqMMC&oauth_nonce=9450269275235606841&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1497530423&oauth_token=2983687160-UrIWQUZK5bbNY9e3Xx9GNZe1OfnUSuE1y3NwF0L&oauth_version=1.0&user_id=%5B1541364193%2C%20378152930%2C%201001674602%2C%2046407661%2C%20338174945%2C%204256170955%2C%2076025806%2C%20128334909%2C%204766003668%2C%20472364403%2C%20776725314%2C%20113168001%2C%20839066041208700929%2C%204258018137%2C%20325766424%2C%201595809370%2C%2022277505%2C%20137118269%2C%20397420741%2C%20367331132%2C%2037489372%2C%203299192225%2C%2018505218%2C%2017090112%2C%20629133%2C%20427696547%2C%202289160027%2C%202976625727%2C%20738538436%2C%20813286%2C%20824473943931293697%2C%2044401576%2C%202999158160%2C%203240143771%2C%202354677800%2C%20237920763%2C%20724171756198608896%2C%20140474586%2C%204661872176%2C%204435227552%2C%20728208660887949313%2C%206792522%2C%201473686120%2C%20160952087%2C%2084038687%2C%20732649152807469056%2C%202869819060%2C%201395320539%2C%201689419970%2C%20510782766%2C%203051229241%2C%20522519631%2C%20756124634186125316%2C%20117115913%2C%202928256157%2C%20710433071313625090%2C%20163689916%2C%20251293035%2C%2015862718%2C%20108140114%2C%20891363019%2C%20222834258%2C%2040931468%2C%203303552016%2C%20741195905685172225%2C%203723167245%2C%20726132381615296512%2C%202907774137%2C%2021588148%2C%2017618048%2C%20226424062%2C%202571133226%2C%202818053218%2C%20278134862%2C%20534637926%2C%204305615136%2C%20245548093%2C%2015178534%2C%202201413052%2C%20519419544%2C%20514396066%2C%201294741%2C%2019587466%2C%203364327647%2C%202360459340%2C%20779416353019203584%2C%20123395124%2C%20733813%2C%20741199962474741760%2C%2030149760%2C%20410034621%2C%20249319425%2C%201191261350%2C%2084623872%2C%202505504208%2C%203107896458%2C%2028406270%2C%20741205276905377797%2C%20105826626%2C%203571233797%5D&oauth_signature=ikUP0TaAbOuyisJsy7r0ysasp%2FA%3D)
details: {'errors': [{'code': 64, 'message': 'Your account is suspended and is not permitted to access this feature.'}]}

Any help would be appreciated

Error in twitter-list-lists.py

Hello,
I am running python 2.7 and 3.5. I also have Anaconda3 installed. In any version I am getting this error:
/media/sf_Temp/python-twitter-examples$ python /media/sf_Temp/python-twitter-examples/twitter-list-lists.py
Traceback (most recent call last):
File "/media/sf_Temp/python-twitter-examples/twitter-list-lists.py", line 23, in
twitter = Twitter(auth=OAuth(config["access_key"], config["access_secret"], config["consumer_key"], config["consumer_secret"]))
NameError: name 'Twitter' is not defined

I cloned your examples to try and learn more about the Twitter api. So I want to run the scripts as is, before hacking around on them.

Any thoughts as to why this is throwing this error?
Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.