2012-08-10 32 views
2

我对这个真的很陌生。从这里到那边阅读我试图用bing search API编写一些代码,但似乎没有发生。bing web查询Api phonegap android

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); 
    }); 

}); 
} 

任何帮助将非常感激。我一直在拉我的头发。

请专家门诊有任何帮助......

回答

1

了Bing API周围已改变,现在是在Windows Azure数据市场下。 http://api.bing.net将不再有效。 check out their migration guide here (.docx format)

个人而言,我在迁移时遇到了问题,因为没有太多的信息写在这个过程中,加上他们正在为他们的API使用收费的废话,我需要用它来开发。这是我的应用程序,我正在建设直出窗口。我讨厌微软这些货币化混蛋的另一个原因。 我希望他们能够做到这一点,所以我不会在第一时间打扰他们的API。同样有趣的是,他们可以抓取网站获取数据,然后按照他们的意愿将其卖掉。