Created
September 13, 2011 10:03
-
-
Save yujikosuga/1213520 to your computer and use it in GitHub Desktop.
An example of facebook post search with retrieving user profile pictures
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var keyword = 'KEYWORD'; | |
FB.api('/search?q=' + keyword + '&type=post', { | |
limit : 10 | |
}, function(response) { | |
var content = ''; | |
var data = response.data; | |
for ( var i in data) { | |
var icon = ''; | |
var nameSpan = ''; | |
var msgSpan = ''; | |
var d = data[i]; | |
if (d.from) { | |
if (d.from.id) { | |
icon = '<img src="http://graph.facebook.com/' + d.from.id + '/picture?type=square" />'; | |
} | |
if (d.from.name) { | |
nameSpan = '<span>' + d.from.name + '</span>'; | |
} | |
} | |
if (d.message) { | |
msgSpan = '<span>' + d.message + '</span>'; | |
} | |
content += | |
'<div>' + | |
'<div>' + icon + '</div>' + | |
'<div>' + nameSpan + msgSpan + '</div>' + | |
'</div>'; | |
} | |
$(root).html(content); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment