//Facebook function fbFetch() { jQuery(document).ready(function($) { //Set Url of JSON data from the facebook graph api. make sure callback is set with a '?' to overcome the cross domain problems with JSON var url = "https://graph.facebook.com/WiMarBuenoPeru/posts?limit=10&access_token=194625310600329|fLcRyALuBG6xSQ2A5mMZ6p7UUBY&callback=?"; //Use jQuery getJSON method to fetch the data from the url and then create our unordered list with the relevant data. $.getJSON(url, function(json) { var html = "<ul>"; //loop through and within data array's retrieve the message variable. $.each(json.data, function(i, fb) { if (fb.from.name == "Recycle Cartons") { if (fb.message != undefined) { var day = fb.created_time.substring(9, 10) + '/'; var month = fb.created_time.substring(6, 7) + '/'; var year = fb.created_time.substring(0, 4) + '/'; html += "<li><div class=\"views-field views-field-created\"><span class=\"field-content\">Update " + timeAgo(fb.created_time) + "</span></div><a href=\"http://www.facebook.com/RecycleCartons?ref=stream\">" + fb.message + "</a></li>"; } } }); html += "</ul>"; //A little animation once fetched $('#facebook-list').animate({ opacity: 0 }, 500, function() { $('#facebook-list').html(html); }); $('#facebook-list').animate({ opacity: 1 }, 500) }); }); }
sábado, 18 de mayo de 2013
Listar noticias de Facebook con jQuery
Si se desea listar las noticias de Facebook con jQuery podemos usar escript.
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario