Twitter Search API - NetworkError: 405 Method Not Allowed

情到浓时终转凉″ 提交于 2019-12-11 04:46:24

问题


I was following this tutorial on how to parse twitter search api requests with jquery.

http://webhole.net/2009/11/28/how-to-read-json-with-javascript/

The code in the post uses a search box for the user to enter the search term and what I simply wanted to do was remove the search part since I know the #tag that I want to search for:

<div id="results"></div>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
    var url='http://search.twitter.com/search.json?q=';
    var query='%23HASHTAGOFMYCHOOSING';
    var options='&result_type=recent&count=5';

    $.getJSON(url+query+options,function(json){
        $.each(json.results,function(i,tweet){
        $("#results").append('<p><img src="'+tweet.profile_image_url+'" width="48" height="48" />'+tweet.text+'</p>');
        });
    });
});

The error I am getting in Firebug is NetworkError: 405 Method Not Allowed and I was just wondering if anyone could shine some light as to why I've broken this code.

Thanks,


回答1:


ah, the problem was that I was missing the callback parameter so the options variable should read as follows:

var options='&result_type=recent&count=5&callback=?';


来源:https://stackoverflow.com/questions/7430492/twitter-search-api-networkerror-405-method-not-allowed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!