I would like to get attending guests count from event using Facebook Graph API v2.1. I can't use FQL Query becouse it is deprecated after current version.
I can use /{event-id}/attending and sum all guests but this solution is very ineffective (queries are performed for a long time - usually >2000ms and it work only for ~1000 guests, not more).
If you make a call to the Event ID itself, you can add fields for attending_count, declined_count and maybe_count to get the totals easily.
Example:
https://graph.facebook.com/{event_id}?fields=attending_count,declined_count,maybe_count
If I do the following:
https://graph.facebook.com/468185256651918?fields=attending_count,declined_count,maybe_count
I see:
{
"attending_count": 304,
"declined_count": 277,
"maybe_count": 97,
"start_time": "2014-09-06T20:00:00+0100",
"id": "468185256651918"
}
Related
Facebook recently added recurrences to their events. So a parent event 887104098135547, will have some event_times like so:
"event_times": [
{
"id": "887104171468873",
"start_time": "2018-06-22T20:00:00+0200",
"end_time": "2018-06-22T21:00:00+0200",
"ticket_uri": "http://www.s-d-a.pl/zapisy/id29/"
},
{
"id": "887104121468878",
"start_time": "2018-06-15T20:00:00+0200",
"end_time": "2018-06-15T21:00:00+0200",
"ticket_uri": "http://www.s-d-a.pl/zapisy/id29/"
},
...
If I start with event recurrence id 887104171468873, I can fetch it and treat it just like a FB Event (name, start_time, end_time, description, place, etc). It represents the singular instance of that recurrence, its times, and the attendees.
However, there is no way to get the parent templated event id, as far as I can tell. And likewise, there is no way to tell that this recurrence event id is actually a recurrence and not a full id. :(
This is causing problems for my system, where sometimes it fetches Pages and gets the parent IDs (and uses them in the system), and sometim[[es it fetches Users and gets the events they're RSVPing too, and gets the recurrence sub-events, with no great way to figure out how to canonicalize them back to the parent ID.
Has anyone else figured out how to do this?
Ok, looks like this is confirmed as being not possible. FB knows it is an issue and it is on their roadmap. https://developers.facebook.com/bugs/126142654873570/?ref=messenger_notif_bug_close
I'm using the Graph API end point referenced below to grab the likes for an object on Facebook.
https://developers.facebook.com/docs/graph-api/reference/v2.1/object/likes
The documentation indicates that I should expect to receive an array of User objects in addition to a field named total_count, which would represent the total number of likes the object has received. I have not been able to get an API response that includes this value - either through my code or via the Graph Explorer.
Has this field already been deprecated? Is there an additional parameter anyone knows of that would trigger the attribute to be returned in the API response?
Is anyone aware of issues with using the solution suggested here?
PageID/posts?fields=comments.limit(1).summary(true),likes.limit(1).summary(true),shares
Add this to the end of your query:
?summary=1
i.e. in graph explorer put: {object-id}/comments?summary=1
( object-id can be the post_id)
Then the total comment count is under this section:
"summary": {
"order": "ranked",
"total_count": 24
}
This is a follow up to: How to filter male and female id in Facebook graph api
Suppose the task at hand is to find 10 female friends of the user. You can perform this with either the FQL or the Graph API (see original question).
Intuitively, I would expect FQL to be much faster because Facebook is taking care of the calculations for you. However, is this necessarily true?
I just ran a quick test (n>=3) using the Graph API Explorer, alternating between the API call and the FQL below.
This API call:
/me/friends?fields=name,gender
returned data from 300ms to 6223ms, avg = 1780ms.
This FQL call:
SELECT name, sex FROM user WHERE uid IN
(SELECT uid2 FROM friend WHERE uid1 = me()) AND sex = "male" LIMIT 10
returned data in 457ms to 8075ms, avg. 3690ms.
So the API call is about 20-30% faster than the FQL call, although the data doesn't match up, so it's really a crap shoot whether the API call will execute faster than the FQL call at any given time.
With the API call you still have to deal with filtering the results on your end to find 10 friends of the gender you're looking for. With FQL you can immediately loop through the result set and display them.
For what it's worth, if you compare an FQL call with everything from the AND on removed, so you're getting similar data to the API, that beats the API easily. Data is returned in 320 to 571 ms, avg. = 390ms.
I'm trying to get demographics for fans of a page on Facebook - mostly country and city, but age and gender as secondary.
The primary way to do it is using FQL and doing a query in the insights table. Like so:
FB.api({
method: 'fql.query',
query: "SELECT metric, value FROM insights WHERE object_id='288162265211' AND metric='page_fans_city' AND end_time=end_time_date('2011-04-16') AND period=period('lifetime')"
}, callback);
The problem with this, however, is that the table returns a maximum of 19 records only, both for the country and the city stats. The response for a page I'm testing is as such:
[
{
"metric": "page_fans_city",
"value": {
"dallas": "12345",
"atlanta": "12340",
(...)
"miami": "12300"
}
}
]
So I'd like to know if there's any alternative to that -- to get demographics of the current fans of a page (no snapshot necessary).
Things I've tried:
Using LIMIT and OFFSET on the query do nothing (other than, sometimes, give me an empty list).
One alternative that has been discussed in the past is to use the "/members" method from the Graph API (more here) to get a list of all users, and then parse through that list. That simply doesn't work - a method exists, and it may have worked in the past, but it's not valid anymore (disabled?).
Request:
https://graph.facebook.com/platform/members?access_token=...
Response:
{"error":
{
"type":"OAuthException",
"message":"(#604) Your statement is not indexable. The WHERE clause must contain an indexable column. Such columns are marked with * in the tables linked from http:\/\/developers.facebook.com\/docs\/reference\/fql "
}}
Other solution was to do a query to the page_fan table and filtering by page_id. This doesn't work, either; it may have worked in the past, but now it says that the page_id column is not indexable therefore it cannot be used (same error as above, which leads me to believe /members uses the same internal API that has been disabled). Page_fan query is only useful to check if individual users are fans of a page.
There's also the like table, but that's only useful for Facebook items (like posts, photos, links, etc), and not Facebook Pages.
Going to the insights website about the Page, you can see the data in some nice graphs and tables, and download an Excel/CSV spreadsheet with the historic demographics data... however, it also limits the data to 19 entries (sometimes 20 with a few holes in there as cities trade top positions though).
Any other hint on how to get that data? I'd either like the insights query with more results, or at least a way to get all the page fans so I could do the location query myself later (even if the page I want to get it from has almost 5 million fans... gulp).
The data pipeline for this metric is currently limited to 20 items. This is a popular feature request and something Facebook hopes to improve soon.
I would like to get work place information of a user using FQL.
When I use the Graph API and get the User object, it contains work information, which is essentially a list of the work history. The list elements contain nodes of employer, location, description, etc...
The nodes appear to be pages internally. If I take the id of a node, e.g. from the employer, and use FQL to query a page with that page_id, I do get an object with corresponding information.
My question now is, how do I use FQL to get the same information without accessing the Graph API? What table stores the work-related information, for example how do I find all the page_id of the employers of a given user?
The reason I insist on using FQL only is performance. Of course I could access the Graph API for all the users in question and get the info that way, but I'm looking for an FQL-only solution.
You can get this information from FQL. Read the "user" table and look for the work field. The JSON data returned should be the same format as the one for Graph, i.e., the result is an array and each result should include an "employer" object with an "id" and "name" field.
You will need user_work_history or friends_work_history to access this field.