Code Monkey home page Code Monkey logo

twitter-rss.php's Introduction

Twitter to RSS

  • Resolves links and embeds pictures, YouTube and other services (besides pictures, all of them require that your RSS reader supports iframes).
  • Uses an SQLite backend to cache resolved urls and stuff.

Instructions

  1. Create a Twitter account.
  2. Create an app on https://apps.twitter.com/
  3. Copy consumer key and consumer secret to variables at the top of twitter-rss.php.
  4. Run the script to get a bearer token.
  5. Copy the bearer token to the source code.
  6. Set up the feeds in your favorite reader, using e.g. twitter-rss.php?user=github
  7. Make sure the url resolution database is created. Otherwise you can try: touch twitter-rss.db; chmod 666 twitter-rss.db

To get history

  1. Request twitter-rss.php?user=github&all
  2. You will be redirected to twitter-rss.php?user=github&all=<timestamp>
  3. This url can be used to fetch all tweets for 30 minutes, after that, it will behave like normal, only fetching the last 200 tweets. The reason for this is to prevent your feed reader from using up the Twitter API limit.
  4. Add this url to your feed reader before the timer runs out. You may have to get a new url since resolving the urls probably took a while.
  5. Note that the API limits the number of tweets you can get to about 3200 tweets.

Misc

To clean up the database (remove urls not seen in the last three days):

sqlite3 twitter-rss.db "DELETE FROM urls WHERE last_seen < strftime('%s','now','-3 days'); VACUUM;"

You may want to create an index on the urls table:

CREATE INDEX url ON urls (url)

Notes

  • It seems that links created in 2011 and earlier don't always have their urls as entities (they are not even autolinked when viewing them on twitter.com).
  • Old tweets don't escape ampersands either.
  • 180 requests can be done per 15 minutes.
  • TODO: Make sure we don't hit the limit.
  • Check your limits by going to twitter-rss.php?limits
  • The PHP extensions php_curl, php_pdo_sqlite, and php_openssl must be enabled.

Docs

twitter-rss.php's People

Contributors

stefansundin avatar aaronbot3000 avatar

Watchers

James Cloos 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.