0
Follow a routine that searches all posts of a particular user via Facebook Graph API
, displays the time it was posted and the message, description and type of post on DIV
:
FB.api(
{
method: 'fql.query',
locale: 'pt_BR',
query: 'SELECT post_id, source_id, message, created_time, type, description, permalink FROM stream WHERE source_id = ' + friend_data[i].id + ' LIMIT 50'
},
function(posts){
if(posts.length>0){
var divFriendsPost = document.getElementById('friend' + posts[0].source_id);
var friendPosts = '';
for(var j=0; j < posts.length ; j++) {
var d = new Date(0);
d.setUTCSeconds(posts[j].created_time);
dateFormat = [d.getDate(), (d.getMonth()+1), d.getFullYear()].join('/');
timeFormat = [d.getHours(), d.getMinutes(), d.getSeconds()].join(':');
if(posts[j].permalink != null && posts[j].permalink != '') {
friendPosts += '<a href="' + posts[j].permalink + '" target="_blank">';
}
friendPosts += '<div class="singlePost">';
friendPosts += '<div class="spLeft">';
friendPosts += '<p>' + dateFormat + '</p>';
friendPosts += '<p>' + timeFormat + '</p>';
friendPosts += '</div>';
friendPosts += '<div class="spRight">';
friendPosts += '<p>' + posts[j].message + '(' + posts[j].type + ')</p>';
friendPosts += '<p>' + posts[j].description +'</p>';
friendPosts += '</div>';
friendPosts += '</div>';
if(posts[j].permalink != null && posts[j].permalink != '') {
friendPosts += '<div>';
friendPosts += '<iframe height="400" src="' + posts[j].permalink + '"></iframe>';
friendPosts += '</div>';
friendPosts += '</a>';
}
}
var newNode = document.createElement('div');
newNode.innerHTML = friendPosts;
divFriendsPost.appendChild(newNode);
}
}
);
The problem is that it is not enough to present this information in the DIV, because most of the time the post is a sharing or publishing photos, for example.
I had the idea to put the link (permalink) in a iframe
under the DIV, but the console returns the following error:
Refused to display 'https://www.facebook.com/...' in a frame because it set 'X-Frame-Options' to 'DENY'.
I believe that facebook blocks this kind of action.
How to solve this problem, i.e., simply show only the post (with nothing around on the facebook page) under the DIV?
It is forbidden to show a post on a own page or it is forbidden to show the link in an iframe?
– Alexandre Bonfá
Simply put: With the exception of pages that already exist in the API, such as buttons and comments, no Facebook page opens in an iframe.
– Gustavo Rodrigues
Uploading any facebook.com url that is not an API via Iframe is prohibited. Visit https://developers.facebook.com/ and see everything they authorize and even make it easy for you to do
– Emerson Rocha
I think he just wants to take the texts of the posts and display, but I didn’t understand right the doubt, too.
– Felipe Avelar
Yes, is prohibited. Doing something that goes against facebook terms of use, if detected, can block your access and all accounts you use. And it can lead to jail in more extreme cases. Example was a developer who made a Crawler that added people and went public admitting it and just wasn’t arrested because he had already helped uncover security holes before.
– Emerson Rocha
Felipe, I have numerous profiles and fan pages that control the content. Entering one by one is a huge job. So I’m making this application to show all posts by date order. Is there any other way to do this?
– Alexandre Bonfá
Alexandre that you are asking and another question. Do not do it here, create a new topic
– Emerson Rocha