• Stars
    star
    911
  • Rank 50,145 (Top 1.0 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 10 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Fetch your twitter posts without using the new Twitter 1.1 API. Pure JavaScript! By Jason Mayes

Twitter-Post-Fetcher

Allows you to get your tweets displaying on your website using JavaScript, without using new Twitter 1.1 API

Further information and project page: http://jasonmayes.com/projects/twitterApi/

Latest version: 18.0.4 - ensure you are using the latest version to avoid issues!

Why does this exist?

Recently I was quite frustrated to find out that the old API on Twitter was depreciated and the overhead in setting up a system to perform OAUTH just to get my already publicly available tweets was too damn high (see https://dev.twitter.com/discussions/11564).

Even worse I couldn't find any simple solutions for JavaScript. All code examples were server side. So after much thinking I invented the following solution. It makes use of the over bloated widgets Twitter gives us to put on our sites, cuts out all the nonsense (and non semantic markup), and returns to you your raw tweet text so you can do with it as you please and style it how you want on your own website - like it should be. Instructions on how to get it working with your tweets are in the code comments, just do what it says! Enjoy!

Browser support

All popular browsers supported. Chrome, Firefox, Safari, Opera, Internet Explorer 7, 8 and 9. Browser Support

Examples

Please read comments in JavaScript for examples on how to use and how to generate a widget id to use with the component - it is really easy! Here are some examples on CodePen:

Key changes / features

  • UPDATE 1: First version released!
  • UPDATE 2: Due to popular demand, you can now specify how many tweets you want returned which can be any number between 1 and 20, as the third parameter to the function call :-) Let me know if you have any other requests below.
  • UPDATE 3: Due to even more requests, solution now gets recent tweets for user, favourite tweets, list tweets, or hashtag search
  • UPDATE 4: Script now handles writing HTML to an element with an ID of your choice making it even simpler to use and allows you to queue up many requests so you can have many items on the same page doing different things eg one might show recent posts with a specific hashtag, whilst the other shows your latest 5 tweets.
  • UPDATE 5: Script now supports grabbing who posted the tweet, their profile photo, and link to profile. Also adds the time they posted at the end. All customizable with CSS to look how you want.
  • UPDATE 6: You can now specify a custom date formatting function to format the twitter post date however you wish! See comments for how to use.
  • UPDATE 7: Now supports IE 7, 8 and 9, Firefox, Chrome, Safari and Opera.
  • UPDATE 8: You can now not show retweets via a new parameter in function call. See comments in code.
  • UPDATE 9: Now supports a custom function callback when data is ready allowing you to have full control over its output.
  • UPDATE 10: Now supports Replying / Retweeting / Favouriting.
  • UPDATE 11: Now includes option to render a tweet's image.
  • UPDATE 13: CommonJS (e.g. Browserify) and AMD (e.g. Require.js) are now supported. See the new examples at the bottom of exampleUsage.js

Got suggestions? Feedback? Feature requests? Tell me!

At time of writing I have made over 132 changes, and many are the result of feature requests from people like you! I want to help all the developers out there get tweets on their sites once again - with ease, as it should be. Talk to me: Via Google+, twitter, or my website.

Disclaimer

This is by no means an official solution - it is something I created to solve a problem I had, and has now grown in to a full component. Twitter may change its system in such a way to cause this to stop working. I of course will try my best to adapt to any changes and all future versions of this code shall be posted here, on this site. I suggest you check back regularly for any updates. This is however the only solution I know of to date to get public data from Twitter without using the new 1.1 API which otherwise requires OAUTH tokens with every request and is a lot harder to set up. Lets keep it simple!

Feel free to use in your own projects. I only ask you keep any disclaimers with my code (even if code is modified / minified) so others can find the original source should they wish to get updates or support. A link back / social media shout out is always appreciated to help others discover it but not required :-)

With that out of the way, I hope you enjoy this component, and that it makes your life a bit easier. Jason Mayes

Notes

If you need IE8 support - ensure you do not set a non block level element as the target to render into. Use a DIV or similar instead. See http://msdn.microsoft.com/en-us/library/ie/ms533897(v=vs.85).aspx This is due to browser, not Twitter Fetcher.

Buy me a beer

It takes time to maintain the component and respond to all your requests. If this has saved you time, or maybe even a client, then some beer money is always appreciated :-) Hit the link on the right of this page: http://jasonmayes.com/projects/twitterApi/

More Repositories

1

Real-Time-Person-Removal

Removing people from complex backgrounds in real time using TensorFlow.js in the web browser
JavaScript
5,173
star
2

Smart-Content-Placer

A small JavaScript class to programmatically position content with variable widths and heights and minimizing whitespace gaps. Imagine Pinterest on steroids (Pinterest only allows for variable height). By Jason Mayes
JavaScript
189
star
3

JS-Motion-Detection

A simple yet fast motion revealing algorithm using the live webcam feed
JavaScript
103
star
4

Tensor-Flow-on-Google-Compute-Engine

A simple script to set up GCE environment in Google Cloud so it is ready to run TensorFlow - an Open Source Software Library for Machine Intelligence
Shell
82
star
5

mdl-component-design-pattern

A design pattern that elegantly handles the registration of new components such that DOM upgrades are automatically performed on document load, as well as making it super easy to handle upgrades of elements that may be added after initial page load.
JavaScript
63
star
6

headless-chrome-nvidia-t4-gpu-support

Using headless Chrome on server side environments for true client side browser emulation with NVIDIA T4 GPUs for Web AI model testing or graphical workloads
Shell
60
star
7

doesVideoContain

JavaScript
48
star
8

Particle-Engine

A simple efficient configurable particle engine written in JavaScript using HTML5 canvas 2D which works on desktop and mobile by Jason Mayes
JavaScript
33
star
9

MP4-video-to-JPG-batch-converter

Specify a directory, this script will search it to find all MP4 videos, convert them to JPGs at a desired FPS and resize them to a given size. Super easy!
Shell
24
star
10

Retraining-TensorFlow-Classifier-Using-Video

Script to convert all MP4 videos in a zip archive to JPG frames at a desired FPS with unique names. It will then retrain the top layers of a binary image classifier using TensorFlow using these extracted images.
Shell
11
star
11

wsk-component-design-pattern

A design pattern that elegantly handles the registration of new components such that DOM upgrades are automatically performed on document load, as well as making it super easy to handle upgrades of elements that may be added after initial page load.
8
star
12

handlebars-helper

A helper component to make it super easy to use handlebars templates in a re-usable manner. Instead of defining script tags inline in your HTML to define templates you can instead write "template files" which will be bought in using AJAX.
JavaScript
7
star
13

Tessel-Multibox-Pointer

Use your Tessel with Google Compute Engine GPU instance running Darknet YOLO via a Node.js server to perform multibox detection over websockets. We can then point a servo at the object of interest and speak out what we see via the speaker.
C
7
star
14

Creative-Technologist-Toolkit

A small library written in Google Closure to do common things fast, useful for rapid prototyping in JavaScript.
JavaScript
4
star
15

dynamic-pages

HTML
1
star