Public
How to get your tweets displaying on your website using JavaScript, without using new Twitter 1.1 API Check out code here: http://jasonmayes.com/projects/twitterApi/ - tested in IE 7, 8, 9 and 10, Firefox, Chrome, Safari and Opera :-)
Today 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 workaround solution. It makes use of the over bloated widgets Twitter gives us to put on our sites, cuts out all the nonsense, and returns to you your raw tweet text so you can do with it as you please on your website. Instructions on how to get it working with your tweets are in the code comments, just do what it says! Check out my JS fiddle here: http://jasonmayes.com/projects/twitterApi/ Enjoy!
UPDATE: 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.
UPDATE 2: Due to even more requests, my solution now gets recent tweets for user, favourite tweets, list tweets, or hashtag search!
UPDATE 3: My 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 shows recent posts with a specific hashtag, whilst the other shows your latest 5 tweets.
UPDATE 4: 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 5: You can now specify a custom date formatting function to format the twitter post date however you wish! See comments for how to use.
Now on GitHub: https://github.com/jasonmayes/Twitter-Post-Fetcher
For further updates please see the project website: http://jasonmayes.com/projects/twitterApi/ all new updates etc will be pushed live here in the future. Questions? Ask below.
#Solution #API #TwitterAPI
Today 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 workaround solution. It makes use of the over bloated widgets Twitter gives us to put on our sites, cuts out all the nonsense, and returns to you your raw tweet text so you can do with it as you please on your website. Instructions on how to get it working with your tweets are in the code comments, just do what it says! Check out my JS fiddle here: http://jasonmayes.com/projects/twitterApi/ Enjoy!
UPDATE: 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.
UPDATE 2: Due to even more requests, my solution now gets recent tweets for user, favourite tweets, list tweets, or hashtag search!
UPDATE 3: My 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 shows recent posts with a specific hashtag, whilst the other shows your latest 5 tweets.
UPDATE 4: 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 5: You can now specify a custom date formatting function to format the twitter post date however you wish! See comments for how to use.
Now on GitHub: https://github.com/jasonmayes/Twitter-Post-Fetcher
For further updates please see the project website: http://jasonmayes.com/projects/twitterApi/ all new updates etc will be pushed live here in the future. Questions? Ask below.
#Solution #API #TwitterAPI

View 310 previous comments
- +Josh Dreier looks like Twitter changed how it works. Unsure at present if it is still returned in this case.Mar 18, 2017
- +Jason Mayes, love this project! Recently Chrome has been complaining about strict MIME type checking: Refused to execute script from 'https://syndi....' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.
My first thought was to change the script.type declaration to 'application/json' — to match the MIME and eliminate the error — but then the script never executes, since it's not text/javascript.
Suggestions on how to make it happy?May 25, 2017 - Chrome isn't the only browser unhappy now; looks like Twitter changed something about their response headers. I suppose modifying your 'script' DOM element to do a full XMLHttpRequest would work around this. Guess there's one way to find out...!May 25, 2017
- Hmph. Version 17.0.0 seems to not have this issue. (v16.0.3 is what I was on)May 25, 2017
- Yep I updated it recently due to the breaking change around mime typesMay 26, 2017
- Wonderful, thanks for confirming the fix!
CheersMay 26, 2017
Add a comment...