我对这个真的很陌生。到处阅读,我尝试使用必应搜索 API 编写一些代码,但似乎没有任何反应。
var appid = "API KEY";
function init() {
document.addEventListener("deviceready", deviceready, true);
}
function deviceready() {
console.log('loaded');
$("#searchButton").bind("touchstart",function() {
var s = $.trim($("#searchField").val());
console.log("going to search for "+s);
$.getJSON("http://api.bing.net/json.aspx?Appid="+appid+"&query="+escape(s)+"&sources=image&image.count=20&Market=%27ar-XA%27&Latitude=11.111&Longitude=11.1111&$top=50", {}, function(res) {
var results = res.SearchResponse.image.Results;
if(results.length == 0) {
$("#results").html("No results!");
return;
}
var s = "";
for(var i=0; i<results.length; i++) {
s+= "<p>"+results[i].Title+"<br/><a href='"+results[i].Url+"'>"+results[i].DisplayUrl+"</a></p>";
}
$("#results").html(s);
});
});
}
任何帮助将不胜感激。我一直在拔头发。
请专家帮忙...
最佳答案
bing api 已经改变了,现在在 windows azure data market 下。 http://api.bing.net将不再工作。 check out their migration guide here (.docx format)
就个人而言,我在迁移过程中遇到了麻烦,因为没有太多关于该过程的信息,而且他们现在对使用他们的 API 收取废话大量的钱,我需要用它来开发。它把我正在构建的应用程序直接抛到了窗外。这只是我讨厌微软这个赚钱的 SCSS 的另一个原因。 我希望他们不会那样做,这样我一开始就不会为他们的 API 而烦恼。有趣的是,他们可以爬取网站获取数据,然后随意出售。
关于javascript - bing 网络搜索 Api phonegap android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11909739/