我使用Twitter api访问 user_timeline
。 我为此使用$.getJson
。
var url = http://api.twitter.com/1/statuses/user_timeline.json?screen_name= +username;
var html = "<div class= feeds >";
$.getJSON ( url, function( data ){
for ( var i in data ){
html += "<div class= feed >" + data[i].text + "</div>";
}
html += "</div>";
$( div.tfeed h2 ).replaceWith ( html );
});
在几次请求后,我开始得到错误 Rate 限制的超值。 客户每小时不能提出超过150个请求 。
。 稍后我就知道, 如果我使用OAuth, 那么这个限制会提高到略高的层次( 如果我错了, 请纠正我), 而这个 OAuth 可以在信头中传递 。 我有消费者钥匙, 消费者机密, 存取权限, 存取权限。 但我如何通过这些?
需要我使用 $.ajax 方法而不是 $.getJson? $.ajax 在 Send 前有一个设置 < code> 。 但是不知道如何使用它 。
那么,
- Can I use
getJSON
for this requirement ? - If no, then will
$.ajax
work? How? - And the important thing should I really use my consumer-key, secret, access-token in javascript. I mean I may be wrong, but any one can do a
view-source
of my page and will quickly get this information.