How to get news feed exactly how it appears in facebook homepage newsfeed using api - facebook

I am using /me/feed and /me/home to get my feed and my homepage feed respectively.
But the /me/home only shows updates from my friends. I am following many people but not friends with them. My facebook homepage shows all the updates including my friends and the people I am following.
How to get the news feed exactly like the one appears in the fb website?

As #Fabio said, the Graph API does not support it as of now (and I don't think it'll do that in the future). You can only obtain yours and your friends' feeds using the Graph API.
In order to obtain the feeds from a specific person who's not in your friend list, you need a valid User Access Token from that user with a read_stream permission.
There is however a way to read the public feeds of user status updates and page status updates as they are posted to Facebook. This can be done by using the Public Feed API. This will include all feeds that have their privacy set to ‘public’ are included in the stream. Also, you cannot apply to use the API at this time as its access is limited. Its page says:
Access to the Public Feed API is restricted to a limited set of media
publishers and usage requires prior approval by Facebook. You cannot
apply to use the API at this time.
But I think it's just a fancy way of saying that this API is not free and you'll be charged few dollars (which you can find out by getting in touch with someone at Facebook) for using this service.

Related

How to get my own Facebook user timeline using Graph API?

I would like to get all the posts and updates that are normally displayed in FB official application for MY account (this includes updates from my friends and liked pages).
I wasn't able to find any details how to get that, the only thing I've managed to get is my own posts.
Anyone got any experience with that using current Graph API verion (3.3)?
All the alternate FB clients (ex. Friendly) must be doing this somehow.
There is no way to get ANY data of users who did not authorized your App. Which means, there is no way to get posts of friends. You can only get your own friends, with the user_posts permission and the /me/posts endpoint. If some Apps access friend data without their authorization, they are most likely doing something that is not allowed.
Here is what I found in their API docs:
There are two scopes:
The user feed requires the user's permission
The public feed has fewer capabilities but doesn't require perms

How to access Instagram feed of any user with new Graph API?

Facebook recently introduced Instagram Graph API, which allows to fetch data from Instagram page that is connected to your Facebook company page, instagram.com/developers states:
The Instagram Graph API is Now Available to All Developers.
For Non-Business Instagram Accounts please continue to use the existing Instagram API.
So, for example, if my company has account instagram.com/my_first_company, I can only retrieve its feed and no one else.
Using old Instagram API to retrieve public_content permission (access to any feed) is no longer an option too, from old API documetation:
public_content - to read any public profile info and media on a user’s
behalf (applications no longer accepted)
What will happen to existing tools that have public_content permission? (for example, there are tons of plugins for various CMS that allow to display recent Instagram photos)
Is there any valid way to access public_content (access to any feed) right now (besides fetching HTML pages of Instagram website)?
Are there any plans to enable Graph API for non-business customers, of so when?
UPD. There seem to be ?__a=1 endpoint that allows to get access to recent photos of any public feed without any tokens. But it's not official and no one knows when/if Instagram will close it. If you do - please let me know.
UPD 2. Instagram removed ?__a=1 endpoint, not sure for how long, probably forever. Currently the only way to access instagram feed is to scrap instagram.com website, which is a horror.
Prerequisite: You first need the business Instagram account to be linked with FB Page. https://help.instagram.com/356902681064399 - That one can do from the profile page of Instagram account.
Get the Instagram business account id:
graph.facebook.com/v2.8/<fbPageId>?fields=instagram_business_account. (the fbPageId is the page id of the facebook page the account is linked)
To fetch instagram media feed: graph.facebook.com/v2.8/<igBusinessId>/media to fetch the media feed of the Instagram account. (the igBusinessId is the id returned in above linked instagram_business_account) - This is still owned media as per the page access_token. Not any other user's feed.
All other endpoints (such as comments moderation, detailed insights API) mentioned here works on the business media list returned on above call.
Please note:
This still does not allow to fetch un-authenticated user's Instagram feed. That is not possible via API now. There is no valid way via API to get to public_content scope. There can be few Instagram Marketing partners for which this is enabled. But, in general the scope is deprecated now!
Currently, for FB graph API to work we need linked business page to Instagram account. As above apis uses page tokens.
You can get information about any IG business account using your FB access_token using the business_discovery API as given here.
You must have an IG business account to read other users data like user_info or media details using the id of your IG business account as a node.
Ex:
GET graph.facebook.com/[YOUR-IG-BUSINESS-ACCOUNT-ID]?fields=business_discovery.username(USERNAME){media{caption,media_url,media_type,like_count,comments_count,id}}

Can the news feed returned by Facebook Graph api be changed to show Most Recent stories?

Using the current (v2.4) Graph api I can see a user's news feed at /{user-id}/home assuming I have the user access token and the read_stream extended permission.
As per the Facebook developer docs, "The posts returned by this API may not be identical to the posts a person would see on facebook.com or in Facebook's mobile apps."
Is there any way—probably undocumented because I can't find it in the official docs—to modify what is returned? e.g. to emulate the Show Most Recent Stories option on facebook.com?
Or to limit the posts to those published by white-listed users, for example?
(I would like to be able to access the public posts of a user's friend. I can't do it via the friend's {user-id}/feed even though the posts are public because of FB's privacy-related API restrictions, but I was hoping to be able to do it via the News Feed, which will only work if the full News Feed is available rather than the limited Top Stories feed returned by default.)
Note: I know similar questions have been asked on SO before but they either haven't been answered categorically or relate to earlier versions of the API.
Both /{user-id}/home endpoint and read_stream permission are deprecated, and will be removed for all apps (no matter what API version they are using) on October 6, 2015 – see https://developers.facebook.com/docs/apps/changelog#v2_4_deprecations
If you want to get posts by the user’s friends, then those friends have to become users of your app and grant it access to their posts first.
I don't know why they deny API access to content that is freely available on facebook.com
Presumably mainly because you are not a Facebook user here viewing content that other people have made accessible to them, but a 3rd party app developer – and in that capacity, you could do all sort of (shady) things with that data if it was freely available to you, like do extended social profiling, data mining, etc. Therefor users must now explicitly agree to share content with your app, before you can access it.
It’s also why they removed all friends_* permissions that existed previously, that allowed people to grant apps access to data belonging to their friends to a certain extend.
Basically it boils down to this: Whether or not a 3rd party app gets access to my data should be my decision, and not that of any Facebook friends of mine.

How to get insights on a Facebook fan page without user login

I'm trying to figure out how to get the total number of comments, posts, likes and fans for any given Facebook fan page and date range using the Facebook API's. I need to be able to do this without the user having to log into Facebook to give the app permissions. This does seem to be possible, as this site is able to do it https://app.conversocial.com/profiler/ .But I don't know how they are doing it.
I've looked into the 'insights' fql table, but this always seems to return empty results. And I've also looked into the 'link_stats' fql table but this doesn't allow a date range to be set.
Does anyone have any idea on how to do this?
You are right. What they are doing is not possible by using the normal Graph API or/and the FQL.
However, Facebook also provides support for two other APIs:
Public Feed API
Keyword Insights API
Access to these APIs is restricted to a limited set of media publishers and usage requires prior approval by Facebook.
I think that they are using the Public Feed API. The documentation of the Public Feed API lists some of the publishers that have been using this API and the site you've mentioned in the question is not in the list. The documentation also doesn't mention anything about getting the Page Insights, but I think it might support this feature (as I see no other way of doing it).
Or, they might be using any other such restricted API which is not yet available to the public and not even documented on the developers website, but is currently in beta/testing phase.
To get the number of fans and the talkabout count, just query the appropriate Open graph ID for the relevant page. For example, for Coca Cola (https://www.facebook.com/cocacola) this is done via
https://graph.facebook.com/40796308305
To get all public infos (Posts etc) use the following request
https://graph.facebook.com/40796308305/feed?access_token={ACCESS_TOKEN}
where {ACCESS_TOKEN} can either be an App Access Token or a personal one. Consider that you can only see public entries.
The ability to query the date ranges is not provided via Facebook ad far as I know. I guess the https://app.conversocial.com/profiler/ application queries each page that is in its index once a day, and saves the results. That's how they're able to provide historical data.
You can try with the following FQL queries or graph API requests for facebook pages,
Graph API
http://graph.facebook.com/nb4cinema
FQL
SELECT name,about,description, fan_count,talking_about_count FROM page WHERE username= 'stackoverflowpage'
In case of FQL tables:
To read the page table you need
no access_token to get public information, or information about public pages that are not demographically restricted.
any valid access_token to get all information about a page that the current session user is able to see.
We have a test fan page. This has poor figures (<10 fans). Statistics are not available due to the lack of fans and likes on that page.
Allthough, conversocial spits out some statistics. They mixed fans and likes to some extent and so my impression is, that they simply parse the page code in order to get what you see.

Facebook Graph API shows different results in me/home

When I do a GET with my browser (already logged-in at Facebook):
https://graph.facebook.com/me/home?access_token={token}
the results are different than doing the same via a FB app using Facebook C# SDK.
Specifically, what the API is not returning are feeds posted by other applications.
Why can be this happening? Can't an application retrieve updates from other applications even if it has the read_stream permission?
I even requested for additional permissions: read_stream,user_activities,friends_activities,friends_likes,user_likes,read_requests
but nothing has changed.
What I need is to get ALL and the same stories an user would see at his FB news feed.
I use
me/feed
me/posts
me/statuses
me/links
Sample for a page: http://apps.facebook.com/anotherfeed/wallfeed.php uses the /pageid/feed
In filtering for my wall plugin. Even with perms, if a friend has interacted with a post and is not sharing interaction the post will not show in Graph. Technically unless you have perms from all friends, and friends of friends you can not fully emulate the wall feed.
I noticed the results are different according the geo-localisation.
If your server is hosted in another country it might be the reason why