1

I am currently creating a Twitter client application. It's just like Tweetdeck or something similar. The different is it's web based and it uses Codeigniter and Elliot Haughin Twitter Library.

I was able to do Oauth and call the twitter home_timeline, user_timeline, and mentions using serverside script. Also, I was able to display that data on the webpage and refresh it every 30 seconds using Jquery.

The problem is the Twitter RESTAPI rate limitation only gives a specific IP address 150 request per hour. With the 30 per second ajax call I made via Jquery, it make my server able to do 120 request to twitter API. The rest 30 requests left is not a problem if I have only one user assuming he/she is only make update status less than 30 req per hour. But, I am sure the more serious problem will occur when I have more user registered to my server.

A friend suggested me to call twitter API directly from jquery so the server side don't need to make a call. It works, but only for public method such as displaying user_timeline. When I tried to call the home_timeline or mentions, the twitter return "401 - authorized error". I understand that the call need OAuth to fulfill the request.

My questions:

  1. Is there any possible way to make a call to authenticated API method directly from Javascript? if it so, how to do it? (i've searched and googling for days but can't find practical solution)

  2. If it so, do I need to include my user request token and secret token along with the call?

  3. Is it safe to include the tokens within javascript?

Please help me. I really appreciate any solution from you guys.

Best Regard

gideon
  • 19,329
  • 11
  • 72
  • 113
under5hell
  • 997
  • 3
  • 16
  • 40
  • 1
    Hmm looks like keeping your key and app secret is the problem. See these links (All possible dupes) : http://stackoverflow.com/questions/2470694/javascript-oauth-sign-in-with-twitter http://stackoverflow.com/questions/1221371/application-that-uses-oauth-and-javascript http://stackoverflow.com/questions/3330500/is-it-possible-to-make-an-100-browser-based-javascript-twitter-client-no-back – gideon Jan 14 '12 at 09:27
  • @gideon : thanks for your reply, from the links I found the best way to do that is trough YQL, it's really interesting but it required my application to integrated with another third party system which is Yahoo API. After googling and searching, I decided to keep my Oauth on serverside because due to security issue. After all, thank you so much for your comment :-) – under5hell Jan 14 '12 at 14:04

0 Answers0