Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
googleapisを利用してFacebookページのウォールを表示するサンプルです。
$(function() {
var formatData = function(date) {
var d = new Date(date);
//ゼロパディング(2桁)にしない場合
//return (d.getFullYear() + '.' + (d.getMonth() + 1) + '.' + d.getDate());
return (d.getFullYear() + '.' + ("0"+(d.getMonth()+1)).slice(-2) + '.' + ("0"+d.getDate()).slice(-2));
};
var replaceURL = function(url){
url = url.replace(/(\/l.php\?u=http%3A%2F%2F)([\x21-\x7e]+)(&h=[\x21-\x7e]+&s=1)/gi,'http://$2');
return unescape(url);
};
$.getJSON(
'http://ajax.googleapis.com/ajax/services/feed/load?callback=?',
{
//xxxxxxxを表示したいFacebookページのidに置き換えてください。
q: 'http://www.facebook.com/feeds/page.php?id=xxxxxx&format=rss20',
v: '1.0',
num: 10
},
function (data) {
$.each(data.responseData.feed.entries, function(i, item){
$('#facebook ul').append('<li><span>'+
formatData(item.publishedDate)
+'</span><br />' + replaceURL(item.content) + '</li>');
});
}
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment