Allora, ora ho capito abbastanza.
Ho copiato il codice del web e modificato tutto in news e News ed inoltre ho cambiato API KEY acquisita su bing Devolopers.
Il problema (che già immaginavo) è che non funziona... perchè non so dove devo mettere la funzione "NewsResult.BreakingNews"
Dove la devo cambiare?
Ecco il codice (sbagliato)
Codice:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Bing Instant with Jquery 9lessons</title>
<meta content='Bing Instant Search with Jquery' name='description'/>
<meta content='Bing Instant, 9lessons, PHP' name='keywords'/>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<!--<script src='http://www.jquery.info/scripts/SearchHighlight.js'></script>-->
<script type="text/javascript">
var offset = 0;
var perPage = 10;
$(document).ready(function()
{
$(".search_input").focus();
$(".search_input").keyup(function(){
search(offset);
});
$('#offset_prev').click(function() {
offset = offset - perPage;
search(offset);
});
$('#offset_next').click(function() {
offset = offset + perPage;
search(offset);
});
function search(offset){
var search_input = $(".search_input").val();
//var search_input = $(this).val();
var keyword= encodeURIComponent(search_input);
var yt_url='http://api.search.live.net/json.aspx?JsonType=callback&JsonCallback=?&Appid=3B9C201E46EC29FA906BEF65B7A97C5B619F0953&query='+keyword+'&sources=news&News.Count='+perPage+'&News.Offset='+offset;
window.location.hash=keyword;
$.ajax({
type: "GET",
url: yt_url,
dataType:"jsonp",
success: function(response)
{
$("#result").html('');
if(response.SearchResponse.News.Results.length)
{
$.each(response.SearchResponse.News.Results, function(i,data)
{
var titlee=data.Title;
var diss=data.Description;
var urll=data.Url;
//var key=keyword;
var key=keyword;
var array_key=key.split("%20");
var array_dis=diss.split(" ");
var dis="";
for(i = 0; i < array_dis.length; i++){
var word_y=word_n="";
for(k = 0; k < array_key.length; k++){
if (array_dis[i].match(array_key[k])) word_y=array_dis[i].replace(array_key[k], "<b>"+array_key[k]+"</b>");
else word_n=array_dis[i];
}
if (word_y) dis=dis+" "+word_y;
else dis=dis+" "+word_n;
}
var array_title=titlee.split(" ");
var title="";
for(i = 0; i < array_title.length; i++){
var word_y=word_n="";
for(k = 0; k < array_key.length; k++){
if (array_title[i].match(array_key[k])) word_y=array_title[i].replace(array_key[k], "<b>"+array_key[k]+"</b>");
else word_n=array_title[i];
}
if (word_y) title=title+" "+word_y;
else title=title+" "+word_n;
}
var array_url=urll.split("/");
var url="";
for(i = 0; i < array_url.length; i++){
var word_y=word_n="";
for(k = 0; k < array_key.length; k++){
if (array_url[i].match(array_key[k])) word_y=array_url[i].replace(array_key[k], "<b>"+array_key[k]+"</b>");
else word_n=array_url[i];
}
if (word_y) url=url+"/"+word_y;
else url=url+"/"+word_n;
}
url=url.substring(1, url.lastIndexOf("/")+1);
var final="<div class='webresult'><div class='title'><a href='"+urll+"'>"+title+"</a></div><div class='desc'>"+dis+"</div><div class='url'>"+url+"</div></div>";
$("#result").append(final);
});
}//if(response.SearchResponse.News.Results.length)
else
{
$("#result").html("<div id='no'>No results</div>");
}
}//function (response)
}); //$.ajax({
}//function search(offset){
//});
});
</script>
<style>
body {
color:#000;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:12px;
}
#container
{
margin:0 auto;
width:700px;
}
.search_input
{
border:2px solid #333;
font-size:20px;
padding:5px;
width:350px;
font-family:'Georgia', Times New Roman, Times, serif;
-moz-border-radius:5px;-webkit-border-radius:5px;
}
#input_box
{
text-align:left;
width:640px;
}
#result
{
text-align:left;
}
#no
{
padding:30px;
font-size:24px;
color:#fff;
}
.title
{
color:#1122CC;
font-family:arial, sans-serif;
font-size:medium;
padding-bottom:5px;
}
.title a
{
color:#1122CC;
text-decoration:underline;
font-family:arial, sans-serif;
}
.desc
{
color:#333;
padding-bottom:5px;
font-size:small;
font-family: arial, sans-serif;
line-height: 16px;
}
.url
{
color:#009A33;
font-size:small;
font-family: arial, sans-serif;
line-height: 15px;
}
.webresult
{
margin-top:10px;
padding-bottom:10px;
padding-left:5px;
}
#offset_prev,#offset_next{
cursor:pointer;
}
</style>
<div id="container">
<div id="input_box">
<!--<img src="bing4.png" /><br/>-->
<input type="text" class='search_input' />
<a id="offset_prev"><<</a>
<a id="offset_next">>></a>
Tutorial link <a href="">click here</a><br/> <br/>
</div>
<div id="result">
</div>
</div>
</body>
</html>
Grazie mille!
P.S Se ora riuscirei a capire come configurare il tutto, forse dopo me la riuscirei a cavare con tutto il resto da solo ;)