Query near public events via Facebook API v2.2 - facebook

I want to retrieve a list of upcoming public events in my hometown from the Facebook Graph API.
I already know that FQL is deprecated and that I can query by keywords using a statement similar to
/v2.2/search?type=event&q=Berlin&since=2015-01-27
However, this list is not enough because there are lots of events which do not contain the City Name either in the event title, description or Location name.
On the other hand I can retrieve a list of places within the same City by using
/v2.2/search?type=place&since=2015-01-27&center=52.52,13.41&distance=10000
In my assumption I could retrieve a better event list if I create a query stating "give me all public events (eid) of all given places within this city in a specified distance".
Does anybody know if this is somehow possible to query?
I am unsure if batch processing is the right way to go, or if there is another possibility to Combine These two entities. My simple Approach would be to query each given Place again by requesting
/v2.2/{placeid}/events
but I also know that Facebook has a rate Limit of 50 requests in this case.

Right now Facebook doesn't have a way to do what you want or at least not documented.
The only way I think you could it is:
1- Find with the facebook API the pages in one city. (You can do do this manually or search for places near the city and then use the places that also ara pages)
2- Get the events of the pages (if exists) and save this in a db also with the location of the place/page.
3- Show all the events of the city.

Related

Retrurning extra fields using the facebook search API

I'm using the facebook graph API to search for all public business within a certain range based on location. I want to return some extra fields, specifically the 'hours of business' but can't see how I can do this?
`search?q=&type=place&center=-33.8650,151.2094&distance=5000'
I realize you can add extra fields in the graph API tool but that is only for things that you have a connection to. Whereas I want to query all 'public' businesses therefore it looks like I'm restricted to use the search functionality
You can use the fields parameter to specify fields you want to see... search?q=&type=place&center=-33.8650,151.2094&distance=5000&fields=hours

Facebook - interests required List<unsigned int32> although Page ID are strings

I currently developed a solution for custom uploading videos for specific customers.
One of my customers need the ability to specify "interests" for a video he upload.
From the API documentation, interests are:
interests
list
One or more IDs of pages to target fans of pages.Use type of page to get possible IDs as find Targeting Options and use the returned id to specify.
There is some mis-documentation regarding this feature: "find Targeting Options" does not talks about type=page.
But, still, I can search for page, using the "search" endpoint: /2.5/search?q=gsw&type=page and get the ID of the page.
As to my understanding, I can specify a page, for example "Golden State Warriors" fan page, specify its id, and then every user which follows this page will be considered as interested in my post.
So, I think my flow should be:
1) Search for the requested page using the "search" api. Get the page's IDS.
2) When creating the video, specify the ID in the "interests" parameter list.
Now, I need to know how to specify the ID in the interests list - The documentation says it list, but the page ID as a number string...
So in conclusion, I would like some help in verifying that all that I have written is correct and make sense, and also to know how to get the int32 id of a page - is it just mistake in the documentaion?
Thanks!

How do I search public status updates within a certain location?

I'm trying to figure out the Graph API, and would like to be able to search through public status updates for specific strings, but only if the status originated from a certain city/place/location. Is this possible? I was thinking if I could find the place_id of a venue or location then I could search the 'status' DB table from there, but I have not been able to figure out the correct search key for that.
Facebook says:
Status search type does not support limit/offset paging.
So the answer would be no, at this time it is not possible to limit to a certain location.
Source https://developers.facebook.com/docs/reference/api/search/

Facebook Graph API Event Paging not working?

I am trying to access past event via Facebook's Graph API.
I am getting current events just right (the one I attended last month and the one in the future) with
https://graph.facebook.com/me/events?access_token=[ACCESS_TOKEN]
However, the paging components "previous" and "next" don't really work, "previous" actually points to a future event that's already been listed in "me/events". While "next" just returns an empty "data" struct.
I also tried "since" with different previous timestamps (such as "me/events?since=1304238280") and it didn't work, it will always return the events that are the same as the ones returned by "me/events". But I definitely have many more past events when I visit
https://www.facebook.com/events/past/
Am I not using the graph API correctly or what? I also noticed there are quite a few questions regarding Graph API's paging problem but there doesn't seem to be a definitive answer yet.
Any info/suggestion/reference would be greatly appreciated!
From what I've seen, it appears that about two weeks after an event ends, Facebook moves the event data out of the events table and into another one that isn't exposed via the API. The internal Facebook servers have access to this table, so you can see past events from within the Facebook webapp.
I'm assuming this is a privacy thing.
try to add the "before" query string with the ID of the first event ex:https://graph.facebook.com/me/events?&before=388551911259170.
you can refer to the following link: https://developers.facebook.com/docs/reference/api/pagination/

Facebook Graph API: Getting the total number of posts

I've been using the Facebook Graph API to display user posts. When I get the initial "page" of posts, the resulting data object has a paging property object with a previous and next URL property. I was hoping to generate navigation links based on this available paging information. However, sometimes these URLs point to an empty set of data, so I obviously don't want to navigate the user to an empty page.
Is there a way to find the total count of objects in a collection so that better navigation can be derived? Is there any way to get smarter paging data?
Update:
Sorry if my post isn't clear. To illustrate, look at the data at https://graph.facebook.com/7901103/posts and its paging property URLs. Then follow those URLs to see the issue: empty pages of data.
Since it pages the datas with date-time base. You can't get the knowledge of whether if there are datas or not before you actually send the request to it. But you can preload the data from previous url to determine is it suitable to dispaly a previous link in your web page.
Why be dependent of Facebook?
Why don't you preload all data for a user and save into a database. Then you fetch the posts from db and show to user. This way you have all the control on how many posts there are and how to manage next and prev.
I was going to try to post this as a comment to your question, but I can't seem to do so...
I know that the Graph API returns JSON, and while I've never come across a way to have the total number of posts returned, depending on what technology you are using to process the response, you might be able to capture the size of the JSON array containing the posts.
For example, if I were using a java application I could use the libraries available at json.org (or Google GSON, or XStream with the JSON driver) to populate an object and then simply use the JSONArray.length() method to check for the number of posts returned.
see:
http://www.json.org/javadoc/org/json/JSONArray.html
It might seem like a bit of a simplistic solution, but might be the type of work around you require if you can't find a way to have Facebook return that data.
Can you specify what technology your application is based in?