I'm using a Facebook application that get all user likes in order to check if a given page is liked using
https://graph.facebook.com/{USER_ID}/likes?access_token={MY_ACCESS_TOKEN}
Everything works fine for me and for the most part of the users, except for some users, that return this:
{
"data": [
]
}
Why does it return an empty data? I already requested the authorization for user_likes in the application
Apps only have access to a user's public information. Even with user_likes permission you will get no Likes data from a user that has set their Likes to private.
Related
I would like to find the id (app-scoped) for someone who has posted a comment on a public page.
For example, I get a list of recent posts/comments on the NY Times page via:
v2.11/nytimes/feed?fields=comments.limit(10){message,created_time,from},name,message,from&limit=2
The data returned looks like this:
"comments": {
"data": [
{
"message": "Wouldn’t know. Not paying $13/mo for this.",
"created_time": "2017-12-10T05:57:18+0000",
"id": "10151412260164999_10151414049324999"
}
],
There is no from field. The same is also true if I attempt to view the comment directly using it's id with
v2.11/10151412260164999_10151414049324999?fields=from,message,created_time
I have tried using the Facebook Graph API Explorer, using both my User Token, as well as an App Token.
Since v2.11 of the Graph API, you need a Page Token to get user data of comments: https://developers.facebook.com/docs/graph-api/changelog/version2.11#gapi-90
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.
In other words: You can only get user information if you manage the Page.
Edit: Since the latests update in the Graph API, you have to get the App reviewed and you must go through Business Verification or Individual Verification. (thanx #Guiman04)
Please check whether you are using the accessToken for the page you are trying to get data from, i had same issue, and was resolved by using the correct accessToken for the page.
I am querying in graph api like this /userid/albums
I am getting response of most users successful but I am though not getting response of some users. It give me blank response-
{
"data": [ ]
}
You need to ask the user for user_photos/friends_photos in order to get the albums of the concerned user or his friends.
After created an app on FB, I get an access token XXX
when I open https://graph.facebook.com/me/likes?access_token=XXX it does show all information that I likes fine.
but when I open to see from another user (who set those info public,such as https://graph.facebook.com/4/likes?access_token=XXX ) I got nothing but
{
"data": [
]
}
Can somebody expand to me why and any idea solve?
You can not view the likes of a public profile, you have to ask for permission(user_likes) from the app to see this info.
Info on the user_likes permissions
user_likes: Provides access to the list of all of the pages the user has liked as the likes connection
Example of Public profile(sorry btaylor, but your name is on the docs )
https://graph.facebook.com/btaylor/likes?access_token=xxx
You will see an empty data set.
From the user docs, talking about the likes connection:
Read
You can read the pages that a User has liked by issuing an HTTP GET to /PROFILE_ID/likes with the user_likes or friends_likes permissions. For example:
https://graph.facebook.com/me/likes
Facebook allows to get list of Likes and Events of a currently authenticated user and his friends by:
https://graph.facebook.com/me/likes
https://graph.facebook.com/[friend's_user_ID]/likes
We need to get list of Likes and Events of people who aren't friends with a currently authenticated user. I tried this to get Likes:
https://graph.facebook.com/[non-friend's_user_ID]/likes
but that only returns the blank response
{
"data": [
]
}
Is there any way to get Likes and Events of non-friends (those who are not my friends)?
If a user's likes are public you should be able to access them with any access token, but otherwise no.
I'm currently working on a facebook app which captures wall posts for a specified user, page or group, after a user has authorized the app I quote the access_token that is returned to call the method
https://graph.facebook.com//feed?access_token=
this works fine for pages and groups as we only need a valid token, however for users the results are different depending on the relationship between the user who authorized the app the user whose posts are being captured.
For example if there is no relationship between the two users some posts are not returned even though they are public and displayed when you view the profile of the user, however if they are friends more posts are returned.
Can someone please explain this behaviour? And is it possible to obtain all posts using this method?
Yes, per the permissions listed at https://developers.facebook.com/docs/reference/api/permissions the results of the call are different depending upon the relationship.
However when things are public and you use an access token that doesn't belong to the user, then no results are returned. I cannot remember a time when this wasn't this way. For some odd reason (by design or omission on Facebook's part) using the graph API to get at public posts using a user access token just doesn't want to work.
For example, You can see some public items here
http://www.facebook.com/zuck
http://graph.facebook.com/zuck
However, you cannot seem to get any feed from here without an access token
https://graph.facebook.com/zuck/feed
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException"
}
}
Let's try adding an user access token that does not belong to zuck or a friend of zuck. https://graph.facebook.com/zuck/feed?access_token={UserAccessToken}
And here's what we get:
{
"data": [
]
}
What about an app access token? Let's try
https://graph.facebook.com/zuck/feed?access_token={AppAccessToken}
{
"error": {
"message": "Invalid OAuth access token signature.",
"type": "OAuthException"
}
}
So as you can see, it's difficult to get things via the graph that are not in alignment with your access token.
I manage to get most of the feeds from user's wall post. Although this is a old post, I hope someone can manage to get what they want from my answer.
Before getting the access token(to get the feeds), you need to add multiple correct Read Permissions "keys".
For example, you will have to add "read_stream", and "user_status" (which I found that these are the most important permission "key" to generate the correct access token, to retrieve one's so-called "public" feeds).
You can add more into generating the access token, in either you want the permission to GET, or POST, or BOTH.
Source is here: https://developers.facebook.com/docs/howtos/ios-6/#nativeauthdialog
One thing that I found is, the way to get the feeds result from user's "Home/About" page and Facebook Page (which is created for people to like (not add friends)) are different. The key is mentioned above, "read_stream", and "user_status". So it's better that you add both of the permissions in order to generate the access token to get everything in feeds.
Graph API doesn't return posts to the App if is not authorized to read user feed, even if posts are public.
Source: https://developers.facebook.com/bugs/290004301178437/
According to the latest api ,
FB.api("/me/feed","get",function(response) {//callback})
should do and also work well .
It is working now but facebook may change it in future.