How to get user likes and other public data - facebook

I am trying to get Facebook public data such as users and groups using the search functionality in graph API. I used long live tokens and also I have granted permissions for my app. Till now, for searching based on user details, I am only able to get the following.
User Name
User Id
For groups and pages:
Id of group or page
Name of group
Category.
But although I have granted permissions in my access token I am unable to get data such as "likes", "comments" etc. Its showing empty data set. How should I proceed so that I can get these information ?

I think you misunderstood how the permissions work. With an access token, you can only query the detailed information for the user which "created" the access token by giving his permission to use the set of his data.
This is not at all valid for all other Facebook users.

Related

Is it posible to use facebook graph api to list a page feed without authorizing APP

I want to access next
graph.facebook.com/pagename/feed/
but I don't want the app to ask the users for permissions, since this information is public available. Is it somehow posible? Until now what I get is:
fbtrace_id
"G69vv730PRn"
message
"(#200) The user hasn't authorized the application to perform this action"
type
"OAuthException"
With an access token generated by explorer.
What I want to do is next:
A user input the page name or id, retrieve last posts, and then for each post retrieve likes and comments.
I mean can't I do something like:
http://graph.facebook.com/v2.7/pagename
and get page information?

Accessing the feed of a facebook group without admin permission

I'm interested in reading the posts in a private group that I'm a part of on Facebook.
Facebook's documentation shows that you can access a facebook group's feed with the following URL:
GET /v2.4/{group-id}/feed
However even after generating an access token with all permissions, this query always returns an empty array (and I know the group in question has posts in it):
{ data: [] }
One answer I have found suggests that this is because you need an access token for a user that is an administrator for the group.
Is this true? If so/otherwise, is there any way to access a facebook group's feed without admin access to the group?
Considering normal users have access to the group's feed, I would certainly expect there to be a way to do this.
The docs at https://developers.facebook.com/docs/graph-api/reference/v2.4/group/feed say:
Permissions
Any valid access token for a public group (i.e. the group's privacy setting is OPEN).
A user access token for a member of the group.
The user_managed_groups permission can be used to read the group content for a group in which the user is an admin. This permission also allows the app to post as the user in the group if the app is also granted the publish_actions permission. An app granted this permission can continue to use these capabilities even if the user stops being an admin of the group, although the user can remove the app from the group manually.
An app access token can read posts it published in app and game groups that belong to it.
Also, have a look at the changelog at https://developers.facebook.com/docs/apps/changelog#v2_4
the user_groups permission has been deprecated. Developers may continue to use the user_managed_groups permission to access the groups a person is the administrator of. This information is still accessed via the /v2.4/{user_id}/groups edge which is still available in v2.4.
So, if you're using v2.4 and the group is private, and you're not an admin of the group, I think you cannot access the group's feed.

Getting Public Facebook Posts with an App Token

I'm using the facebook graph api to access publicly posted information of an arbitrary user. I'm using my own profile for testing and have posted a single public post.
The endpoint that I'm using is:
https:graph.facebook.com/v2.4/{id}/feed
However, this endpoint returns an empty set of data:
{
"data": [
]
}
This occurs regardless of which type of access token I use. I've tried an app access token, a regular access token with no additional permissions, and a regular access token with 'user_posts' selected. I'm especially confused about receiving no data with the last access token as that should include all posts that I've made.
I'd much prefer to use an app access token if possible - it's much easier to get a new one than it is to prompt a user to allow access. What am I doing wrong here?
This can't be done for all users. Facebook requires a person to be logged in order to see public posts from certain users. App credentials won't work to see an arbitrary user's public posts.

Using FQL to retrieve facebook status's of all users who are using My Facebook Application

I would like to retrieve status's of all users who are using my Facebook application.
I am not interested in retrieving the user's friends statuses only interested in retrieving the users who are using my Facebook application and have granted my application the "read_stream" permission.
I can successfully retrieve status's of the logged in user or one of the logged in user's friends by calling:
SELECT post_id, message, attachment, type FROM stream WHERE source_id = "SOME ID" AND type IN (46, 247)
But that is not my goal. I would like to get "All" users who are using my Facebook application and get their latest status feed without any particular user being logged in.
For example: I am not logged in facebook now neither or you. But when you click the link below you will get an RSS Feed of this particular user. This user is actually a business page so it is open to the public. Click This Link
I would like to retrieve this information from users who allow my application "read stream" permissions.
I cannot retrieve this information on personal Facebook user pages. So I am under the impression I need to build a Facebook Application to do so.
There is no way to retrieve a list of the user IDs of your app's users, and if you already have the user IDs you already have the correct query format - you just use the access token from the users to make that call
The fact you can't retrieve a list is covered here: Facebook. How to get list of all users of my app?
If you need the status updates of all your users, you should probably be using the Realtime Updates API to get a notification sent to your app when the user adds a new message, you can then use a cached [and still valid] access token for that user to retrieve the new messages

fetching data using access token

I want to fetch feed/post/statuses data for a particular user.
But found that it is necessary to have an access token.
My concern is , do we need to have a separate access token for every user to fetch their information or merely with a single access token it is possible?
The access token is used to verify that the user making the call is verified and has the correct permissions to perform that action. Every user has his/her own access token for each application. As the comments say above, access tokens expire after a while, so you have to re-request them when the user logs back into your application.
There is also "long-term" access tokens that can be retrieved by requesting the offline_access permission. In this case the access token is valid for (i think) 30 days or until the user changes his/her facebook password.
All the information you need about access tokens can be found at https://developers.facebook.com/docs/authentication/
An Facebook Graph API access token allows you to do what a Facebook application running as a particular user, with a particular set of permissions (https://developers.facebook.com/docs/reference/api/permissions/), is permitted to do. Some data on other Facebook objects (such as users) may be available with the access token of another user, especially if they are a "friend" of the user in the access token.
For example, suppose the access token specifies User A and permission "friends_birthday". You should be able to query the birthday of user B if (1) user B is a friend of user A, and (2) user B permits his/her friends to see his/her birthday.
I don't know your full scenario, but if you are really just fetching data, you may find it easier to use https://facebookpsmodule.codeplex.com rather than writing your own Facebook application.