Does anyone know how I can get a list of events owned (created) by a Facebook page?
I seem to be able to use the "graph api" to generate a list of the events an entity is attending. I also looked at FQL, but it seems to require that the 'where' clause is an indexable field (and, naturally, the id is the only indexable field).
For bonus points, we'd be able to do this without any authentication. (Though I'm resigned to the fact that I'm likely going to need at least a permanent access_token.)
If anyone knows how to do this I'd be eternally grateful.
All FQL data access requires authentication, so forget about those "bonus points".
This is going to require some post-query handling as, like you said, the FQL WHERE clause only respects indexible fields and the owner.id field is not indexible. Thus, we first begin by identifying events the user is a "member" of and loading the owner information for those events.
SELECT id, name, owner.id FROM event WHERE id IN (SELECT eid FROM event_member WHERE uid = XXX)
Once the query returns a dataset, we must manually check for rows in which owner.id is equal to uid.
Looks like you have to first query the event_member table, using the uid
http://developers.facebook.com/docs/reference/fql/event_member
and then once you got the eid of the events you can query the events table where the eid is indexed
http://developers.facebook.com/docs/reference/fql/event
and I'm sure you can use the first as a subquery of the second query like var query = FB.Data.query("select name from event where eid in (select eid from event_member where uid = {0})", user_id);
This one does it
select eid from event where creator=".$facebookPageId." and eid in (select eid from event_member where uid=".$facebookPageId.") ORDER BY start_time DESC
This link has a good tutorial on FB events and many more on C#.
http://blog.impact-works.com/2011/07/
But he uses a dll which he created. But as soon as you get the idea out of the blog, you can use Facebook c# Sdk to develop whatever you want to develop.
And all these info is valid for you IFF you are developing in c# my friend.
use this get request
https://graph.facebook.com/'your facebook page ID'/events?access_token=' your application token'&limit='number of events wanted'&after=1&fields=owner,name,description,cover,id
first you must create a facebook application and get its "app token"
In the fileds column you can specify the details you want about the event using the names in facebook API https://developers.facebook.com/docs/graph-api/reference/event/
Related
So I've done a bit of reading up on the FQL documentation, but I haven't managed to find the answer to my current problem. Given a single user, I want to get back a list of attendees (per event) that are going to events that the user is also attending.
NOTE: (I am using a StringTemplate, so I provide the proper uid through the render function later)
With this query, I am able to get all the events for a particular user.
SELECT eid from event_member WHERE uid={{}} AND start_time > 0
With this query, I am able to get all the users for a single event.
SELECT uid, eid FROM event_member WHERE uid = {{}}
SELECT uid, eid FROM event_member WHERE eid in (SELECT eid FROM #a)
However, when I try the following query, which I found here: Facebook Graph to show Event Attendees
SELECT eid, uid FROM event_member WHERE eid IN (SELECT eid FROM event_member WHERE uid = {{}} AND rsvp_status = {{}})
I am returned with nothing. Any ideas? Thank you for your time and help!
Ok, so after some more research, I've decided to use the Facebook Graph API instead. This is what people are moving towards, eventually, so it's best to get on board.
The query I used in the graph api to get all attendees for all events that a particular user is also attending was:
https://graph.facebook.com/v1.0/{{}}?fields=events.since(0).fields(name, attending)
This query will return the events the user is going to in addition to all of the other attendees per event.
I'm trying to get All public events for given location. Here is what I'm using now
SELECT+name,+pic_cover,start_time,+end_time,+location,+description,venue++FROM+event+WHERE+eid++in(SELECT+eid+FROM+event_member+WHERE+uid+IN+(SELECT+page_id+FROM+place+WHERE+distance(latitude,+longitude,+"40.1811",+"44.5136")+<+50000+limit+0,15000))+ORDER+BY+start_time+desc+limit+0,1500
But there are huge count of events with that location which didn't returning with that FQL query.
Is there any chance to get all events for given location or it may be by City ?
I'm using Python , but if you have some example code on any language please write it out.
I think if you omit the subquery for the event_member table, you'll eventually get more results. Please consider that the results will only include Events created by the Page itself, not those created by individual users.
SELECT name, pic_cover,start_time, end_time, location, description,venue FROM event WHERE creator IN (SELECT page_id FROM place WHERE distance(latitude, longitude, "40.1811", "44.5136") < 50000 limit 0,15000) and start_time > now() ORDER BY start_time desc limit 0,1500
If you have a list of venues of interest, you could use the method I described here: Facebook FQL find all events that take place at a certain venue
Edit 2017-12-20:
As it is now impossible to use FQL if the app was created after 2014-04-30, a direct search is no longer possible. To achieve that, a three-step approach must be used, as implemented in https://github.com/tobilg/facebook-events-by-location-core for example.
I would like to execute an FQL query for retrieving all the public events in a specific area (using longitude,latitude and maximum distance or simply location name). Do you know if it's possible?
Apparently, somebody is able to do it, somehow: http://elmcity.info/fb_events?location=tokyo
It is possible indeed to receive events using location based "search"
To do so you'll need the longitude and latitude coordinates of the location you want to search and a access_token with user_events permission (i think you could also use the public search)
Here's an FQL example how can you get all the events nearby of a location. (this searches from your and your friends events):
$lat = "40";
$long = "30";
// using offset gives us a "square" on the map from where to search the events
$offset = 0.4;
$events = 'SELECT pic_big, name, venue, location, start_time, eid FROM event WHERE eid IN (SELECT eid FROM event_member WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND start_time > '. $created_time .' OR uid = me()) AND start_time > '. $created_time .' AND venue.longitude < \''. ($long+$offset) .'\' AND venue.latitude < \''. ($lat+$offset) .'\' AND venue.longitude > \''. ($long-$offset) .'\' AND venue.latitude > \''. ($lat-$offset) .'\' ORDER BY start_time ASC '. $limit;
The trick itself lies in the venue.longitude and venue.latitude useage. To get events from a city, just get the city coordinates and adjust the offset to your needs.
If you don't know how to use FQL please look into Facebook PHP SDK
I'm wrestling with this same problem right now. It does not look possible. There are several problems I see:
the location fields are not searchable in the page or place tables,
the way event locations are populated is inconsistent: See this page's events for an example. (I personally populated most of these. These are FB changes, not user error.),
FQL does not have an AS statement to query based on the result of a calculation, and
Facebook limits the amount of items returned by a query to some fairly low value.
What the referenced site seems to do is query event.description for the presence of the input string. Query "IKEA", and you'll get lots of results. Definitely not a geo search. (BTW, the site's source code is on GitHub).
Edit:
Okay, I was wrong. Facebook does expose a search method, but only in the Graph API. Using the batch request functionality, you could execute a series of requests that:
Find all place entries within a distance (in meters) of a known lat/long. The graph api accepts q=* for the search string to return all places.
Query event to find all events at the places returned above.
I'm going to play with this. I'll update this post again as I flesh out this code better.
try this code worked for me returns all details of the upcoming public event which contains a specific key word that can be your location
SELECT eid,name,description,venue,creator,location,ticket_uri,start_time, eid,host,not_replied_count,pic_square,pic_big,unsure_count,attending_count,declined_count,all_members_count FROM event WHERE start_time > now() AND CONTAINS("your location name") AND privacy='open'
I believe that in http://elmcity.info/fb_events?location=tokyo they are not really searching for events in Tokyo, they simply executing a query like this
https://graph.facebook.com/search?type=event&q=tokyo
(access token is needed, see https://developers.facebook.com/tools/explorer?method=GET&path=search%3Ftype%3Devent%26q%3Dhaifa)
Note that this url also works
http://elmcity.info/fb_events?location=sport
I'm also looking for a way to retrieve public events using fql and so far I didn't find any.
I can't seem to be able to access past events in the graph api, it only seems to give me access to the current events, either the events API is broken, or facebook does not provide access to past events, but there is nothing in the docs that would suggest that...
I'm having a similar problem. There is a workaround using FQL, though it will only display current events and past events from the last 2 weeks.
Example Query:
SELECT name, pic_small, eid from event WHERE eid in (SELECT eid FROM event_member WHERE uid = me())
You need to set "start_time" condition in your query.Works for me.
FQL example that retrieves current & past events :
SELECT name FROM event WHERE eid in (
SELECT eid FROM event_member
WHERE uid = {you page or user id here}
AND start_time > '2001-11-02T12:35:00+0200'
)
Since FQL doesn't support ( Select * ), address FQL manual to query more fields https://developers.facebook.com/docs/reference/fql/
I'm having a similar problem. There is a workaround using FQL, though it will only display current events and past events from the last 2 weeks.
Example Query:
SELECT name, pic_small, eid from event WHERE eid in (SELECT eid FROM event_member WHERE uid = me())
It turns out the Facebook pagination is broken for events, but there is a walk around by setting the "since" parameter to 0 and paginating upwards ans oppose to backwards...
I am using FQL to get the list of friends
$fql = select uid, name, work_history,
education_history, current_location
from user where uid IN (select uid2
from friend where
uid1=FACEBOOK_USER_ID);
does this query returns same friend sequence all the time or it is different in few cases.
suppose list returns : Friend1,friend2,friend3 .... etc
So does it return the same sequence all the time or not?
Please let me know if any further detail required or if the problem is not clear.
-deepak
I'd take all doubt out of the equation and just add an ORDER BY:
SELECT uid, name, work_history, education_history, current_location
FROM user
WHERE uid IN (select uid2 from friend where uid1=<FACEBOOK_USER_ID>)
ORDER BY uid
It appears that they come back in sequential order based on the user id. So if you had three friends with the user ids 111111, 222222, and 3333333, they would be returned in that order.
With THAT said, I wouldn't rely on this behavior. Even if it never changes, it is probably bad practice to assume it will always be that way. It's a much better practice to get the data, then order it on your end to your needs. That way you know it is always in the order you want even if the ordering on Facebook's end changes.