Twitter sketch deployed in js

I have a sketch that uses twitter4j working perfectly. It is based on streaming API. Id like to put it online without using an applet. So I've gone studying some js to try to handle the twitter querying part of the sketch from javaScript. Then I found that js is not really the best way to handle twitter's streaming API, among others reasons because it would expose the API keys... The client side js is no good for messing with twitter. Well now I'm thinking that I may need to learn some server side language to try to accomplish that... A server app would open the stream, javaScript would connect to that app/stream and Processing would be like my graphical lib called from js. Now for the questions?

1- Does this makes sense? Any experience on this subject to throw some light in?

2- Which server side language would you recommend for me to start with?

thanks for reading : )

(hope I have chosen the right session)

Answers

  • Hi @_vk (nice name ;) ) I recently made this page (source on Github) which came across a lot of the same issues. I don't really have any server side programming experience, but this was fairly straightforward to set up (although I'm not using the streaming API, I'm not sure how big a difference that would make?). I followed this tutorial to authenticate with Twitter. I knew enough JSON+jQuery to hack it together from there, although there's an example here. You could probably pass those details to Processing.js?

    The other thing I had to do was set up a cron job on the server to regularly poll the Twitter API (I set it for every minute) and write to a text file, otherwise your API key can get blocked if you go over your request limit if a lot of people hit your site at once — this tutorial set me on the right path for that.

    Overall, this required pretty much 0 PHP knowledge, but it works fine. Hope that's of use to you.

  • Hi @velvetkevorkian thanks a lot for all the input, code samples and encouragement. I'll dig into it as soon as I can. In a glance It looks pretty much as what I need. I think the Stream API will have some particularity, but fore sure it is possible. I'll get back with my results. tx

  • Answer ✓
    • Yes, it makes sense, it avoid issues with JS calling another server (if JsonP isn't supported) and improves confidentiality.
    • First question to ask: what language can you run on your server? For most free hosts, it is limited to PHP... Otherwise, nearly all languages, including Java, can be used server-side. Choose one with a Twitter library... :-)
Sign In or Register to comment.