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;
Related
I use the facebook api to crawl post from one page wall. The post will be published by random facebook users. The posts are shown on a landingpage.
That work's very fine for the first dev tests. But since we have switch into a live version (now random user write posts) where are some posts that are not in the facebook api's response.
My first thought was that the privacy setting of the post is not public. But then I shouldn't see it when I am logout.
Why I didn't see that few posts? Have someone a tip?
$url = '/' . $pageId . '/feed?fields=from, message, id, link, type, created_time, updated_time, shares, object_id,comments.limit(1).summary(true),likes.limit(1).summary(true)&since=' . $since;
Try adding &filter=stream to your call.
Facebook will defaults to a "Top Story" feed which can hide some objects due to a low "score". This will force the return to be in a "Most Recent" style feed where all objects will be shown and in chronological order.
My Idea: Some posts are missing in the api because of the privacy setting of facebook user? Maybe because the profile is not visible for non-facebook users? The publicity of the posts on facebook wall is always public when i look at the facebook wall. Have somebody experience with that?
I want to get a number of posts from a page in last month. Is is possible with facebook graph API? Also FYI, i just have the access_token to interact with the Facebook API.
Also do anyone knows how to fetch the number of Page mentions in last month?
Thanks for your help in advance.
Try using Facebook's Page Insights using Facebook Graph API's :
https://developers.facebook.com/docs/graph-api/reference/insights/#page_posts
But please note that you need to be a page admin for this page, and you need to acquire a Page Access Token with the permissions 'read_insights'.
If you are not a page admin, then you can also do the same with an User Access Token or an App Access Token.
Steps:
`int postsCount = 0;
Use the following API query https://graph.facebook.com/{page-id}/posts and issue a reuquest.
Count the posts fetched. postsCount = postsCount + {the posts json array size}.
Store the cursor returned by the above API result. Use it to fetch the next page of Posts.
If the {the posts json array size} > 0, then goto step 3.
Notes:
I am sure that you can do it better with FQL, but I am guessing FQL is being deprecated.
I think there is a summary(true) annotation (https://graph.facebook.com/{page-id}?fields=posts.summary(true)) that you can use, but I couldn't get it working.
There is an API rate limit that you need to keep in mind. And do some throttling.
So, the moral of the story is that I am not sure if Facebook really wants you to crawl its Pages if you are not the Admin of the page. :-)
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
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
Is there an API call, and if so, which call to get the 'posts to my wall from myself and others' on Facebook? It seems like it could be filtered out of the Facebook stream API, but it's not clear how that works to me.
This link seems to imply it's possible:
http://developers.facebook.com/news.php?blog=1&story=225
You want to do an FQL query like this:
SELECT actor_id, message FROM stream WHERE source_id = <user id> limit 50
You will probably want to select a few more fields, you can see what is available here: http://wiki.developers.facebook.com/index.php/Stream_%28FQL%29
Here it is.
Profile feed (Wall): https://graph.facebook.com/me/feed?access_token=...
https://developers.facebook.com/blog/post/465
You can publish stories to people who like your Open Graph Page the same way you write a Facebook post from your own wall. The stories appear in the News Feeds of people who have clicked the Like button on the Open Graph Page.
You can also publish using our API. If you associate your Open Graph Page with a Facebook app using the fb:app_id meta tag, you can publish updates to the users who have liked your pages via the Graph API.
First you need to get an access token for your app.
Check out the blog post, it covers everything you need.