This question already has answers here:
Facebook JS SDK's FB.api('/me') method doesn't return the fields I expect in Graph API v2.4+
(4 answers)
Closed 6 years ago.
I'm trying to get my information with the Graph API node "me" using the Graph API Explorer to make some tests.
If I use the version v2.5(latest) only "id" and "name" fields are retrieved.
But if I use the v2.3 or earlier versions, more information like "birthday", "first_name", "gender", "last_name" are retrieved.
I need all information like older version but want to use the latest one. What must I do different?
It is called "Declarative Fields" and came with v2.4. You now have to specify the fields you want to get, or you will only get the id and name:
/me?fields=name,first_name,last_name,birthday
Of course you have to authorize the user with user_birthday to get his birthday.
Changelog: https://developers.facebook.com/docs/apps/changelog#v2_4
Related
This question already has answers here:
Facebook JS SDK's FB.api('/me') method doesn't return the fields I expect in Graph API v2.4+
(4 answers)
Closed 6 years ago.
So I want to use the api but when I use /{event-id}/feed
I get the follwing:
* message
* date
* id
But what I also like is the name of the user who posted the message. How can I achieve this?
The API-References says that you get An array of Post objects as result.
These Post objects contain detailed information about the message.
For example the field "from": Information about the profile that posted the message.
If the creator of the message is a normal user, from will contain an User object. This object contains the fields first_name and last_name.
When I GET /{group-id}?fields=link I get just get back {group-id}, rather than a full URL like in the case of /{album-id}?fields=link, /{photo-id}?fields=link, etc. Sample request and response for a group:
GET /v2.5/1685218945065439?fields=link
{
"id": "1685218945065439"
}
whereas an album looks like this:
GET /v2.5/1685219628398704?fields=link
{
"link": "https://www.facebook.com/media/set/?set=oa.1685219628398704&type=1",
"id": "1685219628398704"
}
According to the docs link is a valid field on the Group object. I'm using a token that has user_managed_groups. I see the same result when querying OPEN and CLOSED groups.
Just looking at the URLs of my groups by loading them in my web browser, I see that they all use the format https://www.facebook.com/groups/{group-id}/, so it's easy enough to build a URL from the {group-id}, but is that URL format something I can actually count on?
Using Graph API v2.5.
This is a field that is kept around for historical reasons. Back in the day you were able to actually set a website for a group, for example https://example.com.
This functionality has since been removed from the UI on facebook.com but the field in the API is present as older groups might have this value set, but newer groups won't have it anymore.
There has been a bug report about this as well which has been closed as 'By Design' for the reasons mentioned above https://developers.facebook.com/bugs/1495489670770155/
I filed a bug report to which the Facebook team responded that this is the intended behavior (also noted by Bjorn in his answer). See Bjorn's answer for more details.
The good news is that, according to the Facebook dev on that bug report, the format of the Group URL will always be https://www.facebook.com/groups/GROUP_ID, so there's really no need to query the API for the Group URL anyways.
I have an App that needs to query a users's profile post.
For any post, I'm trying to figure out:
the number of people (profiles) mentioned and
the names of the people (profiles) mentioned
Assume the user has already given the App access to view their profile data.
See here: https://developers.facebook.com/docs/graph-api/reference/v2.3/post
According to the documentation, if a user mentions 2 profiles, say "Friend1" and "Friend2" then I should be able to get back a response that includes the field:
which has some profile information for "Friend1" and "Friend2".
The problem I'm having is given the GET query
https://graph.facebook.com/v2.3/10207722160149556_10207755501343065
I get the response:
{:created_time "2015-11-08T09:29:54+0000", :message "Friend1 Friend2 testing again sorry just ignore", :id "10207722160149556_10207755501343065"}
I don't get a to field or for that matter a bunch of other information?
Does anyone know how I can get back what is listed in the documentation as what I should be getting?
Any help would be appreciated
In case this helps, these are the permissions I'm currently requesting:
["user_photos" "user_friends" "publish_actions"
"user_posts" "user_likes" "user_relationships"
"user_about_me" "email" "public_profile"
"user_tagged_places"]
Kind regards,
Jason.
Sorry, bad case of not reading the documentation and a library that I was using that got in the way.
I have to include a "field" query param to specify what I want returned.
After that and validating with a curl call I can get the information I need.
I am using the Facebook API from Java with Facebook4j.
I have two servers, on the one that uses Facebook 2.3 API when I get the from of a post,
Post post = connection.getFeed().get(0);
post.getFrom();
I get the user, but in the server that uses Facebook 2.4 API, the from is null.
Any idea? I don't see any documented change in the fb API.
As described in the Facebook Platform Changelog, as of v2.4, you now have to manually specify fields if you want them to be retrieved:
To try to improve performance on mobile networks, Nodes and Edges in
v2.4 requires that you explicitly request the field(s) you need for
your GET requests. For example, GET /v2.4/me/feed no longer includes
likes and comments by default, but GET
/v2.4/me/feed?fields=comments,likes will return the data. For more
details see the docs on how to request specific fields.
According to the docs on Post, the relevant field is named from. To request this field in the me feed using Facebook4J, you can use a Reading object, as follows:
facebook.getFeed(new Reading().fields("from"))
Since Facebook's Graph API changed to version 2.4, I find that any query attempting to retrieve posts made returns an error:
type: OAuthException, code: 1, message: An unknown error has occurred. [HTTP 500]
My request code uses Facebook's koala ruby api to make requests:
posts = #graph.get_object(appid+"/posts?limit=20",api_version: "v2.3")
I added the version count now, based on koala's recommendation, but the result for this is still the same error that I got without specifying the version. My access token is definitely valid, does anyone know if something else has changed or if this is a bug?
Extending #Tobi 's comment. You have to pass a page/event/user/group id to retrieve the post.
Also, you've to explicitly pass fields parameter to query additional data of a post. So your query will become:
posts = #graph.get_object(id+"/posts?fields=id,name,message,picture&limit=20",api_version: "v2.4")
Please refer to this document of Facebook Developers to learn more about /postsedge.