facebook api, is event id universally unique - facebook

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.

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

Facebook Marketing API Campaign spend_cap field returns inconsistently

I'm trying to pull data for each of my Ad Campaigns from the Facebook Marketing API.
In the Ads Insights API there is only a 'spend' field that returns how much of the budget for that campaign has been spent so within the specified date range parameter. This is documented at
developers.facebook.com/docs/marketing-api/insights/fields/v2.9
I would like to get the 'spend_cap' field that's specified in the Reference section of the Marketing API located in the link below. One thing I noted was that there are no parameters available to this node, that may be why the spend_cap is not returning. This is documented at
developers.facebook.com/docs/marketing-api/reference/ad-campaign-group
I am using the following url to request the data.
https://graph.facebook.com/v2.9/{act_id}/campaigns?fields=name,spend_cap&access_token={access_token}
However, it returns the spend_cap field inconsistently, as shown below. I've only included a couple examples but I'm certain that all my campaigns are set up with spending caps.
data:[
{
"id": "##############",
"name": "name1",
"start_time": "2016-06-24T14:47:34-0400",
"stop_time": "2016-07-03T14:47:34-0400"
},
{
"id": "##############",
"name": "name2",
"spend_cap": "30000",
"start_time": "2016-05-16T11:57:10-0400"
},
{
"id": "##############",
"name": "name3",
"spend_cap": "15000",
"start_time": "2016-05-16T11:44:06-0400",
"stop_time": "2017-04-01T00:00:00-0400"
},
{
"id": "##############",
"name": "name4",
"start_time": "2016-05-13T15:34:41-0400",
"stop_time": "2017-05-13T09:46:44-0400"
}
]
The spend_cap at the campaign level is an optional field which is why it is only returned for some of the campaigns.
In general within the Graph API, if a field contains no data, this field will be omitted from the response.
Our SDKs abstract this for you so you can always access a field of an object, regardless of whether it was in the response, so if you're not using one of our SDKs, you'll have to do the same.

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

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

Facebook Ignore Graph API Page Posts Connection - Ignore Replies & Comments? Story vs Message

I'm pulling page posts from the Graph API, but I would like to ignore comments or replies.
So for instance:
{
"id": "115673336230_10151050684306231",
"from": {
"name": "New York Jets",
"category": "Professional sports team",
"id": "115673336230"
},
"story": "\"Well said, Michael. We know our...\" on [User's name removed]'s post on New York Jets's wall.",
"story_tags": {
"40": [
{
"id": ----------,
"name": ------------,
"offset": 40,
"length": 15,
"type": "user"
}
]
},
"type": "status",
"created_time": "2012-09-27T13:39:55+0000",
"updated_time": "2012-09-27T13:39:55+0000",
"comments": {
"count": 0
}
}`
There doesn't seem to be any piece of this response that I can use to filter a reply like this out other than the 'on User's Name post' bit in the story field.
I've noticed that all of the replies to comments appear without message data and with story data, but from the docs its unclear if this would be a reliable data point to filter against.
Is there a way to ignore comments/replies in the Page posts connection? Do all Page Posts (non comment replies) have data in the message field and never in the story field? That is, can I reliably ignore 'posts' that have no message? That have a story?
If you want more powerful filtering, you should look at querying the stream table with FQL.
The type field allows you to filter out posts based on what they are. Adding AND type != 247 will exclude comments from the data returned.
There might be a way to do this using the API by requesting the status_type field, but then you'll have to also manually request all other fields you want to display, and you'll still end up filtering them in your script.

Determining which fields and connections are returned in a FB.api query

When I query Facebook via FB.api with the following:
me/events
A JSON event array in the returned JSON object has information for the fields "name", "start_tile", "end_time", "location", "id", and "rsvp_status". I know I can obtain information on additional fields and connections (such as the "picture" connection or the "owner" field) by parsing the "id" field and querying the individual event directly but is there a way to request this information in the initial query so I can avoid the extra FB.api calls?
{
"name": "Example Name",
"start_time": "2012-05-04T22:00:00",
"end_time": "2012-05-05T01:00:00",
"location": "Example Location",
"id": "xxxxxxxxxxxx",
"rsvp_status": "attending"
}
From https://developers.facebook.com/docs/reference/api/
Introspection
The Graph API supports introspection of objects, which enables you to
see all of the connections an object has without knowing its type
ahead of time. To get this information, add metadata=1 to the object
URL, and the resulting JSON will include a metadata property that
lists all the supported connections for the given object. For example,
you can see all the connections for the Developer Garage event above
by fetching https://graph.facebook.com/331218348435?metadata=1. That
outputs:
{
"name": "Facebook Developer Garage Austin - SXSW Edition",
"metadata": {
"connections": {
"feed": "https://graph.facebook.com/331218348435/feed",
"picture": "https://graph.facebook.com/331218348435/picture",
"invited": "https://graph.facebook.com/331218348435/invited",
"attending": "https://graph.facebook.com/331218348435/attending",
"maybe": "https://graph.facebook.com/331218348435/maybe",
"noreply": "https://graph.facebook.com/331218348435/noreply",
"declined": "https://graph.facebook.com/331218348435/declined"
}
}
}