GithubHelp home page GithubHelp logo

rlugojr / twitter-streamer-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from internetmosquito/twitter-streamer

0.0 2.0 0.0 240 KB

An example project that shows how to get all tweets from a specific user using the Streaming API and Tweepy

License: GNU General Public License v3.0

Python 84.37% CSS 0.46% HTML 15.18%

twitter-streamer-1's Introduction

twitter-streamer

An example project that shows how to get all tweets from a specific user using the Streaming API and Tweepy.

It uses a Flask app to get the access token from the user we want to get tweets from and a Puller (puller.py) that gets data from Twitter once credentials are stored in credentials.txt

Incoming tweets are stored in a mongoDB database, using 2 collection.

There is view /messages that will show all tweets from past 7 days stored in the db.

I made this so other people could reuse it, it was kinda hard to find proper documentation on how to do this.

Requirements


  • Flask 0.10.1
  • Jinja 2.7.3
  • Tweepy 0.1.2
  • Pymongo 2.8

You'll need to have mongoDB up and running in your test machine

Flask is used to handle callback methods while having the Oauth dance with Twitter and also to show incoming messages from the account that allows this app to get tweets from the timeline

Thus, you'll basically need to follow this steps to make this work:

1.- Go to dev.twitter.com and create your Twitter application 2.- You will then need to copy your application token and secret and put it in app.py and puller.py

CONSUMER_TOKEN = 'your_app_token'
CONSUMER_SECRET = 'your_app_secret'

3.- You'll need to specify the callback URL to finish the verification process. I recommend using something like ngrok if you're working locally, it will let you tweak Twitter to think your dev machine is a real server.

CALLBACK_URL = 'your_callback_url/verify'

3.- Install mongoDB or specify where your mongoDB server is at app.py and puller.py

4.- All the pulling logic can be done with puller.py, but if you haven't authenticated the user yet and there is no credentials file, you'll need to start the Flask app in order to perform the oAuth dance, just go to / and if there is no credentials file you should be re-directed to Twitter

4.- Fire up the app and then go to http://localhost:5000 (if you use the embedded Flask server), this will start the verification process, unless you already had an access token/secret stored in the credentials.txt file. If successfull, you'll be redirected to http://localhost:5000/messages, which is just a landing page that, well, does nothing.

5.- In order to see incoming messages, go to http://localhost:5000/messages, there is a table that will be filled with incoming messages from the user account that authorized the app (last 7 days of stored tweets)

Overall the code can be surely improved, so feel free to fork and do as you please, just let me know how it goes :)

twitter-streamer-1's People

Contributors

internetmosquito avatar

Watchers

 avatar  avatar

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.