Skip to content

Instantly share code, notes, and snippets.

@k-ishiwata
Created October 9, 2012 04:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save k-ishiwata/3856549 to your computer and use it in GitHub Desktop.
Save k-ishiwata/3856549 to your computer and use it in GitHub Desktop.
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