English 中文(简体)
我能使用GetJSON方法设置推特头版吗?
原标题:Can I set twitter header using getJSON method?

我使用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> 。 但是不知道如何使用它 。

那么,

  1. Can I use getJSON for this requirement ?
  2. If no, then will $.ajax work? How?
  3. 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.
问题回答

$.getJSON 只是带有数据Type:json的$.ajax 的简称。

我会在服务器上创建一个新的服务, 使用你的秘密设备, 让它用您现在使用的“ jaxcall” - & gt; 返回 JSON 的响应。 希望您能理解这个想法, 否则的话, 错误的表达 。

c# 使用 c# api 使用“ 机密” 变量的样本

OAuthTokens accessToken = new OAuthTokens();
accessToken.ConsumerKey = "XXXXXXXXXXXXXXXXXXXXXXXX";
accessToken.ConsumerSecret = "XXXXXXXXXXXXXXXXXXXXXXXXXX";
accessToken.AccessToken = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
accessToken.AccessTokenSecret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

您是在使用 ASP. NET 或 PHP 吗?





相关问题
How to suppress/remove PHP session cookie

I need to suppress an already set session cookie header, but I cannot find any way to do this. Why? I need to make an image, sent by a PHP script, cacheable by the end user; this image is used to ...

Why is my page still executing?

I have a form that posts to a processing script which checks for errors in the post. Depending on the processing it header redirects to another location. This appeared to work but I have just noticed ...

How to stop floating (sliding) div at footer

How can I have a sliding menu div that doesn t move unless the page is scrolled down past a certain point I used the code from this link for a floating menu. it has how to stop the stop float at ...

Better way to share header file between separate vc project?

How would you organize your vc projects source code to share the same header file? put the header in a common folder, and have every vc projects include it. put the header in a vc project, and have ...

how to tell clicking "back" to load cache?

I would like for my site when someone clicks "Back" or "Forward" for the server to tell the browser to load the cache instead of reloading the entire page. I ve tested some headers and done research, ...

热门标签