domingo, 18 de mayo de 2014

Blogger JSON con jQuery ajax


Ay una forma de obtener datos desde blogger utilizando elFeed blogger Json por medio de este podemos crear diapositivas,elementos relacionados,obtener los comentarios etc infinidad de cosas.
un problema o desventaja seria utilizar javascripten ciertas circunstancias puederalentizarel proceso de carga de sublog ,así que para resolver ese problema podemos utilizar jQuery ajax que se adapta perfectamente y reduce el código que se va a utilizar y es mucho mas fácil de manejar.

Primero debemos saber que datos pedir por medio de la url del blog añadiendo el feed y para obtener los datos necesitamos añadir el Json con un parámetroalt=json-in-script.


http://www.example.com/feeds/posts/default?alt=json-in-script

Tabla de Parámetros del Feed


ObjectDescriptionExample
json.feed.id.$tMostrar blog IDtag:blogger.com,1999:blog-85047
json.feed.updated.$tÚltima actualización de un blog2012-02-08T18:21:57.051+07:00
json.feed.category[]Categorías / etiqueta de conjunto de un blog
json.feed.category[i].termDemuestre la categoría i-ésimoBlogger and widget
json.feed.title.$tNombre Mostrar blogThreelas
json.feed.subtitle.$tMostrar descripción de un blogThreelas is a good site in the world
json.feed.author[]Arsenal de los autores del blogPutri Arisnawati, Ibnu Syuhada
json.feed.author[i].name.$tMostrar el nombre de autor del blog i-ésimoPutri Arisnawati
json.feed.author[i].uri.$tMostrar el perfil de autor uri-i thhttps://profiles.google.com/116848xxx
json.feed.openSearch$totalResults.$tMostrar mensajes en total222
json.feed.entry[]Posts array of a blog
json.feed.entry[i].id.$tMostrar el registro ID i-ésimotag:blogger.com,1999:blog-8508.post-578455349
json.feed.entry[i].title.$tMostrar el registro del título i-ésimoBasic Blogger JSON Feed API
json.feed.entry[i].published.$tMostrar cuando el puesto número i se actualiza2012-02-07T12:56:00.000+07:00
json.feed.entry[i].updated.$tMostrar variedad de categorías de correos2012-02-07T12:56:47.089+07:00
json.feed.entry[i].category[]Show array of post categories
json.feed.entry[i].category[j].termDemuestre la categoría j-ésima del puesto número iBlogger Api
json.feed.entry[i].content.$tMostrar contenido de mensajeThis post is explain about using JSON feed ...
json.feed.entry[i].link[]Enlaces matriz de un puesto
json.feed.entry[i].link[j].hrefMostrar el enlace j-ésimo del puesto número ihttp://www.example.com/2012/02/does.html
json.feed.entry[i].author[]Arsenal de los autores de correos
json.feed.entry[i].author[j].name.$tNombre de la authro j-ésimo en el post-iésimoPutri Arisnawati
json.feed.entry[i].author[j].uri.$tMostrar perfil de autor urihttps://profiles.google.com/116848xxx
json.feed.entry[i].author[j].gd$image.srcImagen uri del autor perfil j-ésimo en el post-i-ésimo//lh4.googleusercontent.com/photo.jpg
json.feed.entry[i].media$thumbnail.urlMostrar una imagen en el mensaje de orden ihttp://3.bp.blogspot.com/Allen+Mills.jpg
json.feed.entry[i].thr$total.$t
Mostrar el total de roscado comentarios
5

Utilizando el ajax

function getBuscar(value){
var ruta="http://www.tublog.blogspot.com/feeds/posts/summary?alt=json-in-script&q="+value+"&max-results=9999"+"&callback=?";
var xhr= $.ajax({
url: ruta,
type: 'get',
dataType: "jsonp",
success: function(data) {

var url_post=null,imagen_post=null,titulo_post=null;
var entradas = [];

for(var i=0; idata.feed.entry.length; i++){

for (var j=0; j data.feed.entry[i].link.length; j++)
{
if (data.feed.entry[i].link[j].rel == 'alternate')
{
url_post = data.feed.entry[i].link[j].href;
break;
}
}

imagen_post = data.feed.entry[i].media$thumbnail.url.replace(/\/s72\-c/, "/s240-c");
titulo_post = data.feed.entry[i].title.$t;

console.log("Entrada:"+url_post+" "+titulo_post+" "+imagen_post);
}

},
error: function(response) {
console.log("ERROR AL CARGAR-URL NO VALIDA:"+response);
}
});

}

Por medio de consola podre saber la llegada de los datos o los post buscados,el procedimientogetBuscar(value) recibe el valor a buscar a buscar que seria el titulo del post el parámetro "&q=" añadido a la URL de datosrecibirá el valor a buscar y "&max-results=" la cantidad de resultados a mostrar en este caso seria la cantidad de entradas a mostrar por ahora solo obtendremos la imagen y titulo del post, en otra entrada haremos algo mas elaborado

Donate Car To Charity CALIFORNIA DONATE CAR FOR TAX CREDITDONATE CARS IN MADONATE YOUR CAR SACRAMENTOHOW TO DONATE A CAR IN CALIFORNIA DONATE YOUR CAR FOR KIDS,CAR INSURANCE QUOTES COLORADO ,NUNAVUT CULTURE,DAYTON FREIGHT LINESHARDDRIVE DATA RECOVERY SERVICES,DONATE A CAR IN MARYLAND,MOTOR REPLACEMENTS,CHEAP DOMAIN REGISTRATION HOSTING,DONATING A CAR IN MARYLANDMundial Football history FIFA World Cup,smart,huge/big,scienciemedia,blog spot and amazes,unites pero for you gives ,, inspires and future now help and pero mas aya del visita and Mesothelioma law firm CHEAP CAR INSURANCE IN VIRGINIA,Selling annuity payments for cashSelling annuity payments for cash,Sell my structured settlement,Sell structured settlement,Structured settlement,Structured settlement companies,Sell my annuity payments lump sum,Car accident lawyer Denver,Accident injury attorneys,Sell my annuity

MESOTHELIOMA LAW FIRMDONATE CAR TO CHARITY CALIFORNIAHARDDRIVE DATA RECOVERY SERVICESDONATE A CAR IN MARYLAND DONATING A CAR IN MARYLAND,DONATE CARS ILLINOIS,CRIMINAL DEFENSE ATTORNEYS FLORIDA ,BEST CRIMINAL LAWYER IN ARIZONASTRUCTURED ANNUITY SETTLEMENT,ASBESTOS LAWYERS,NUNAVUT CULTURE,DAYTON FREIGHT LINES ,Bextra Bankruptcy Dental Plan Private JetMundial Football Mesothelioma law firm,mega life and health FIFA World Cup es un buen servicio en las distintas naciones trans union pero resulto que tenia cancer y fui a asbestos cancer y me dijeron en asbestos mesothelioma que tambien padecia de prostate cancer treatment y un daño tremendo a mi organismo fui a malignant pleural mesothelioma,asi que hice un prestamo en credit repair y otro en chase credit pero de pronto un anti spam software asi que decido un auto en rental car in costa rica me registre en Facebook en internet domain registration y tambien obtuve un domain registration,Selling annuity payments for cash,Selling annuity payments for cash,Sell my structured settlement,Sell structured settlement,Structured settlement,Structured settlement companies,Sell my annuity payments lump sum,Car accident lawyer Denver,Accident injury attorneys,Sell my annuity

MESOTHELIOMA LAW FIRMDONATE CAR TO CHARITY CALIFORNIAHARDDRIVE DATA RECOVERY SERVICESDONATE A CAR IN MARYLAND DONATING A CAR IN MARYLAND,DONATE CARS ILLINOIS,CRIMINAL DEFENSE ATTORNEYS FLORIDA ,BEST CRIMINAL LAWYER IN ARIZONASTRUCTURED ANNUITY SETTLEMENT,ASBESTOS LAWYERS,NUNAVUT CULTURE,DAYTON FREIGHT LINES ,Bextra Bankruptcy Dental Plan Private JetMundial FootballFIFA World Cup Vestidos de Perros y gatosHosting Dominio web movilSelling annuity payments for cashSelling annuity payments for cash,Sell my structured settlement,Sell structured settlement,Structured settlementStructured settlement companies,Sell my annuity payments lump sum,Car accident lawyer Denver,Accident injury attorneys,Sell my annuity

,

No hay comentarios:

Publicar un comentario