Reputation: 2815
So I'm trying out the Facebook API functions, and finally got the authentication stuff to work. But now I'm trying to display a users feed, more specifically only the story/message/description (doesn't know the difference) itself:
So, I have this code:
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
alert('Good to see you, ' + response.name + '.');
});
FB.api('/me/home', function(response) {
console.log(response.data);
});
}
Which gives me a bunch of arrays containing the different stories etc, which look like this:
Now, what I want is how to display only the descriptions itself, after each other. How would you do this? This question is maybe more directly related to JS itself, than Facebook, but they use some special tags and names. Maybe use some sort of foreach code will do the trick?
Thanks in advance :)
Upvotes: 0
Views: 42
Reputation: 429
if you run console.dir(response.data) in chrome or firebug then each of the properties will be shown for each of the objects in the data array.
from there you can perform the following
for(var i=0, len = response.data.length; i < len; i++){ console.log(response.data[i].propertyNameYouWant
}
Upvotes: 1