Get only timeline posts, from facebook feed request - facebook

I'm trying to build an app using facebook's JS SDK and Graph API, and got a little confused in process. The idea is simply to take every post user have created on his timeline. As listed in docs to do this you need to call feed connection, to get an array of post object representing posts users make to their wall.
The thing is when using standard request to get last 30 post (with read_stream permission)
FB.api('/me/feed?limit=30&format=json', function(response) {
//operations on response.data
}
in response graph api returns not only the timeline posts user made, but also some of comments on other peoples posts. So it seems feed doesn't return just "The user's wall." posts, as written in doc, but all things user posted. Request to */user_id/posts* is giving pretty much the same result.
The confusing part is that user text posts to his/hers timeline and comments on other people's posts have the same type of "status". The difference between them is that timeline post has it's content in "message" field and comment stores text in "story".
So my question: Is there a way to sort only timeline posts made by user, within a request itself?

So after facebook updated it's docs it is now clear that you need to call /{user-id}/posts to show only the posts that were published by user.
Call to /{user-id}/feed on the other hand returns the feed of posts, including status updates and links published by user, or by others on user's profile.
More about so called "derivative edges" here: https://developers.facebook.com/docs/graph-api/reference/user/#edges

Related

Getting Facebook comments "From" field using Graph API [duplicate]

Recently, when using the /feed Facebook Graph API method, it has stopped returning the From field. This field typically contains the Id and Name of the author of the Facebook Post in question.
The URL I'm hitting is https://graph.facebook.com/{id}/feed?fields={my-fields-here}&access_token={token}
From what I can tell, the From field still exists within the API: If I try https://graph.facebook.com/{id}/feed?fields=id,from&access_token={token} I get a list of IDs (no Froms though), without errors.
However, if I try a deliberately-invalid field name, such as https://graph.facebook.com/{id}/feed?fields=id,doesnotexist&access_token={token} then I get an error response of (#100) Unknown fields: doesnotexist.
So the From field still exists as far as the Facebook Graph API is concerned. It's just no longer being returned. Did something change recently? The From field is also still listed as the list of fields over on their documentation. As far as the data itself goes, posts dating months back also no longer have From, so it's not a case of "newer posts in the feed lack the field, but older posts do either."
I'm at a loss! If anyone could lend a hand, I'd appreciate it.
It is only included if you use a Page Token. v2.11 of the Graph API (90-Day Breaking Changes):
/page/* — User information will not be included in GET responses for
any objects owned by (on) a Page unless the request is made with a
Page access token. This affects all nodes and edges that return data
for objects owned by a Page.
Source: https://developers.facebook.com/docs/graph-api/changelog/version2.11
...or in the link of your question:
Any valid access token can read posts on a public Page, but responses
will not include User information.
A Page access token can read all Posts posted to or posted by that Page, and responses will include User information.

Automatically find public posts and comments on Facebook and unlike/remove them?

I'm using Facebook for many years, and I've liked and commented a lot of friends posts (status, photos, etc). The problem is that I didn't pay attention to that these posts were "public" or "for friends only". As a result, a person who is not a friends of mine can now see all these contents using a request of Graph Search like:
Photos liked by USERNAME
Posts liked by USERNAME
Posts commented on by USERNAME
...
Of course I could remove likes and comments one by one from the Activity log, but it would take several months... I could also use the Toolkit for Facebook available on Chrome, but unfortunately it only proposes to remove ALL likes or comments, of any kind, whereas I want to do it only for public ones.
Edit: This Chrome pluggin is actually a fake, don't use it!
Is there a way to do it with Graph API?
This post seems to mention there isn't, but I'm not sure. I found this post for instance.
Edit: #CBroe confirms "Facebook has recently removed the ability to (un-)like objects in the name of the user" so I guess the latter link is obsolete?
Admitting we've retrieved the posts or comments ID, for instance by parsing the html response of the Graph Search result, then:
Is there another way to launch a request to FB which unlikes or removes posts/comments?
What do you think about it?
Thanks!

How can I make my timeline with Graph API?

I've studied Facebook API for several hours, and googled lots of pages. But I can not find the way get posts list just like my timeline on Facebook app.
I would like to make a Web app that show my timeline posts just like Flipboard. I found an API to get my "story" and "my friends list". But I can not even imagine how to retrieve my friend post that shown on my timeline.
Is it impossible to replicate my timeline on my web app? Only Flipboard can do that? Do you have any hint?
To access the current User's News Feed use the "User/Home" request as described in the API Documentation.
In order to gain access to the User's News Feed you will be required to gain the "read_stream" permission. For information on how to request the appropriate permission, read the Login, authorization and permissions section of the Getting Started guide.
The request to me/home will return an array of News Feed items, which are comprised of statuses, pictures, likes, etc. You can see an example of the result by using the Graph API Explorer.
Compare the results to your Timeline and they should be nearly identical (currently I believe Ads/Promoted Posts are excluded from the API)"
Play around with the Graph API Explorer:
https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Fhome
I had to change the permissions within the App and specifically give myself 'read_stream' access, but once that was complete I was able to run a '/me/home' Graph API GET Request and return a representation of my timeline. Good luck!
You can get the timeline this way:
$fb = new Facebook('{config}');
$fb->setDefaultAccessToken('{getAccesstoken}');
$request = $fb->get('/me?fields=feed.limit(10000){link}');
//
$graphObject = $request->getGraphNode();
return $graphObject;

Getting others' posts on a Facebook page's timeline

I'm using https://graph.facebook.com/JellyBelly/posts (with an access token) to get all the posts on a page's timeline. However, I'm getting only posts made by the page itself.
How can I also get posts by others?
Could it be that my query also returns posts the page made on other pages/users? I'm not sure it does, but want to know if my query is supposed to only retrieve posts from this page's timeline?
/PAGE_ID/posts give the Page's own posts as described at https://developers.facebook.com/docs/reference/api/page/
To get posts by others you need
/PAGE_ID/feed
or in your case
/JellyBelly/feed

Get Facebook Page Feed and their likes/comments without any permissions

I am trying to get the user ids of all the users who have liked or commented on a status on a facebook page.
I tried using graph.facebook.com/page_id/posts?access_token=...
but it only gives me 2-4 user ids who have liked and their total count, similarly for comments. Is there any way to get all the ids?
According to The Documentation for the 'Post' object
(and verified by me on my own page using the Graph API Explorer tool), these work:
/POST_ID/comments to fetch the comments
/POST_ID/likesto fetch the Likes