How to get gender of users attending some event (Facebook Graph API)? - facebook

Is there a way to get gender of facebook users via Facebook Graph API, that are attending some event? Or just by users' ids?

You can consume the events/attending endpoint:
https://developers.facebook.com/docs/graph-api/reference/v2.2/event/attending
Your request would be /{TheEventId}/attending
Which returns a list of user objects:
https://developers.facebook.com/docs/graph-api/reference/v2.2/user
...which looks like this:
{
"data": [
{
"name": "What What",
"rsvp_status": "attending",
"id": "10152412233197215"
},
{
"name": "What What",
"rsvp_status": "attending",
"id": "1682602711966379"
},
{
"name": "What What",
"rsvp_status": "attending",
"id": "10201675684423330"
}
]
You would then need to use the user id to query for each user's details. The user object has a gender field.
{
"id": "10142215948176947",
"gender": "male",
...
}
Also note the permission limitations:
gender & locale can only be accessed if:
The person queried is the person using the app.
The person queried is using the app, and is a friend of the person using the app.
The person queried is using the app, is not a friend of the person using the app, but the app includes either an app access token or
an appsecret_proof argument with the call

Related

Facebook Graph API - Get user profile from conversations

by using Facebook Graph API I can fetch the conversations between users and my page. One of the returned conversations looks like this:
{
"message": "message content",
"from": {
"name": "My Page's Name",
"email": "198301820627381#facebook.com",
"id": "198301820627381",
},
"to": {
"data": [
{
"name": "John Doe",
"email": "396169264164870#facebook.com",
"id": "396169264164870",
}
]
},
"id": "m_mid.$cAADurJ0X8UhnJ3tfxVg9jYXJW5fp"
}
I see that I got the user's id field. How can I fetch this user's profile (first name, last name, profile pic) base on this field ? (or is there another way ?)
I followed the Graph API's User Reference but all I got are the user's id and name (which I already have from the returned conversation).
profile_pic only works for PSIDs (Messenger bot events), for ASIDs just use the picture field instead

Is it possible to get user detailed using facebook API V2.6

I am using the "taggable_friends" api to get the list of all friends then uses the user ID (a string of 110 chars) to get user detailes like this:
FB.api('/' + gFriend.id , 'GET',{},
function(response) {
console.log("response",response)
});
In the result I get an error
(#803) Some of the aliases you requested do not exist: {The user Id I have submitted}
Did FB blocked user details API in version 2?
taggable_friends if for tagging only, you can´t use it for anything else and you don´t get a User ID. You only get a "tagging token" that can only be used for tagging. If you just want to create a "friend pic collage", you need to use /me/friends instead. Of course you will only get friends who authorized your app with the user_friends permission.
[from comments] I want to show friend pic collage
The taggable_friends endpoint does return URLs of the friend’s profile pictures already.
You get a data structure like this,
{
"data": [
{
"id": "AaKYNqeDaP…",
"name": "Foo Barski",
"picture": {
"data": {
"is_silhouette": false,
"url": "https://scontent.xx.fbcdn.net/v/t1.0-1/p50x50/…"
}
}
},
{
"id": "AaKBGEbAAvYU…",
"name": "Some One Else",
"picture": {
"data": {
"is_silhouette": false,
"url": "https://scontent.xx.fbcdn.net/v/t1.0-1/p50x50/…"
}
}
},
So all you need to do is use those URLs provided in the picture structure.

facebook api, is event id universally unique

The user's event data is as below. I'm wonder the id 157881474402440 is unique among all events (private, public, belong to any person) in Facebook graph since I'm intending to use it to export to a calendar system as the UID of event (I'll append it with something like "_facebook"). Tks
"events": {
"data": [
{
"name": "Return match vs Wollongong",
"start_time": "2013-08-10T14:00:00+1000",
"end_time": "2013-08-10T17:00:00+1000",
"timezone": "Australia/Sydney",
"location": "Wentworth park field 1",
"rsvp_status": "attending",
"id": "157881474402440"
}
],
Every object on facebook has unique object id. you can verify it by getting the event details from two different facebook accounts having access to the event.

FB Graph API: Way to get list of fields for an object through API

Is there a way how to get the list of fields for a specific facebook object programmatically?
I know there's documentation for that, but I need some introspection - we're building a tool that would enable the user to select from existing fields.
I mean something like: give me a list of fields for user, response: {"id", "name", "first_name", ...}
Or some way how to get all the fields for one object and derive it from that?
Facebook enables you to pass metadata=1 parameter. For example
cocacola?metadata=1
gives you all available connections and fields for the page:
"metadata": {
"connections": {
"admins": "https://graph.facebook.com/cocacola/admins",
"admin_settings": "https://graph.facebook.com/cocacola/admin_settings"
},
"fields": [
{
"name": "id",
"description": "The Page's ID. No access token or user `access_token`. `string`."
},
{
"name": "name",
"description": "The Page's name. No access token or user `access_token`. `string`."
},
{
"name": "link",
"description": "Link to the page on Facebook. No access token or user `access_token`. `string` containing a valid URL."
},
{
"name": "category_lists",
"description": "The Page's categories. No access token or user `access_token`. `string`."
},
{
"name": "is_published",
"description": "Indicates whether the page is published and visible to non-admins. No access token or user `access_token`. `boolean`."
}
Looks like it's official, found it in the getting started manual

Facebook smart friendlist via API

Trying to retrieve friends on smart (auto-generated) friendlists via the API, but it is returning no data.
Via graph explorer: /<friendlist id>?fields=members
If this is a custom list (not auto-generated) this returns:
{
"id": "<friendlist id>",
"members": {
"data": [
{
"id": "<friend id>",
"name": "<name>"
}
]
}
}
However, with auto-generated lists I seem to get just the id back and no members.
This seems to be a known bug for smart lists:
http://developers.facebook.com/bugs/471978009483097/