[英]Jquery twitter feed not returning any results
I was using this code to retrieve twitter feed. 我正在使用此代码来检索Twitter feed。 It was workign fine but all of a sudden the query stop returning any data. 工作正常,但查询突然停止返回任何数据。 How can I make this work? 我该如何进行这项工作?
Here is the code below: 这是下面的代码:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () // don't do anything until the document is loaded.
{
$("#submit").click(function (event) { // wire up this as an onclick event to the submit button.
var searchTerm = $("#search").val(); // get the user-entered search term
var baseUrl = "http://search.twitter.com/search.json?q=";
$.getJSON(baseUrl + searchTerm + "&rpp=1500&callback=?", function (data) // call getJSON providing the complete url with search term and a JSONP callback
{
$("#tweets").empty(); // clear out any previous results.
if (data.results.length < 1)
$('#tweets').html("No results. Nada. Nuttin. Zippo.");
$.each(data.results, function () // iterate over the results, constructing the HTML for the display.
{
$('<div align="justify"></div>')
.hide()
.append('<img src="' + this.profile_image_url + '" width="80px" /> ')
.append('<span><a href="http://www.twitter.com/' + this.from_user + '">' + this.from_user + '</a> ' + makeLink(this.text) + '</span>')
.appendTo('#tweets') // append the constructed results HTML to the tweets div
.fadeIn(2000); // fade in the results over 2 seconds.
});
});
});
});
function makeLink(text) // this REGEX converts http(s) links that are embedded in the tweeet text into real hyperlinks.
{
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
return text.replace(exp, "<a href='$1'>$1</a>");
}
</script>
</HEAD>
<BODY style="margin-left:20%;margin-right:20%">
<div align="center">
<h2>Twitter tag search</h2>
<div>Enter Search Term</div>
<input type="text" id=search />
<input type="button" id=submit value="Search" />
<DIV id="tweets" />
</div>
Version 1.0 of the Twitter api was deprecated in on June 11, 2013 so the http://search.twitter.com/search.json endpoint will no longer work. Twitter api的1.0版已于2013年6月11日弃用,因此http://search.twitter.com/search.json终结点将不再起作用。 You'll need to migrate to version 1.1 which now requires authentication for every request. 您需要迁移到1.1版,该版本现在需要对每个请求进行身份验证。 You can find more information here . 您可以在此处找到更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.