How i can get all events from all registered users by using Graph API? - facebook

I work on iPhone application that grab events from different channel and show them on map.
Now i try to grab Facebook events in my DB.
I make this request
SELECT name, venue, location, start_time, update_time FROM event WHERE update_time>1358294400
But it doesn't work. Facebook return
{
"error": {
"message": "Error validating access token: Session has expired at unix time 1358528400. The current unix time is 1358761880.",
"type": "OAuthException",
"code": 190,
"error_subcode": 463
}
}
How can i get events by update_time ?
Thanks in advance.

I guess you can not. Since-
The WHERE clause must contain an indexable column. Such columns are marked with * in the tables.
and updated_time is not an indexable column. Only eid and name are indexable in the table event.
So, simply get all the data and then filter manually according to the updated_time

Related

Tried accessing nonexisting field (fql) on node type (User)

FQL requests fail since wednesday. I have no clue why since FQL is supposed to be deprecated only at the end of April.
Basically, here is the type of requests that worked until wednesday :
https://graph.facebook.com/89240001803405/fql?access_token=<access_code>&q=select+is_published%2C+talking_about_count%2C+access_token%2C+description%2C+emails%2C+fan_count%2C+general_info%2C+location%2C+page_url%2C+pic_square%2C+username%2C+page_id%2Cname+from+page+WHERE+page_id+IN+%28SELECT+page_id+FROM+page_admin+where+uid+%3D+89240001803405%29
And here is the current response :
{
"error": {
"message": "(#100) Tried accessing nonexisting field (fql) on node type (User)",
"type": "OAuthException",
"code": 100
}
}
Any idea how I can fix this before I migrate de non FQL ?
Thanks
The user id you have in there before the fql part is wrong, as far as I know. If that has worked before, then rather by accident, I guess.
FQL calls via API endpoint should be of the form https://graph.facebook.com/fql?q=… – the identifier fql as first path segment, follow by parameters such as q for the query, the access token and what else might be appropriate.
Specifying the user id first doesn’t make sense, because what data you want to select you define inside the query itself.

FQL NoIndexFunctionException on indexed field

I'm trying to query the created time for a facebook link by executing the following fql question
SELECT created_time FROM link WHERE owner = me()
according to the developers documentation (https://developers.facebook.com/docs/reference/fql/link) the owner field is indexed but the graph api throws the following exception.
{
"error": {
"message": "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 ",
"type": "NoIndexFunctionException",
"code": 604
}
}
what is wrong with my query?
Select the FQL Query button above the text box on the Graph API Explorer and it works fine. The links go to the Graph API editor instead of the FQL editor, which is wrong.
Example

FQL: Know email, first name and last name. What is the FQL code to get the User ID on Facebook?

I only know the email, first name and last name of a person. Is it possible to get the User ID through FQL? Thank you.
The columns which u are having from the user table in facebook are not indexable. For fetching using the where clause u must have a indexable column. If u will try with these columns u will get the following error
{
"error": {
"message": "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 ",
"type": "NoIndexFunctionException",
"code": 604
}
}
So for getting User ID you need to have any of the indexable columns.

FQL getting a list of non-friend from my current location

I would like to know how to get a list of id facebook's user from my current location,
I just did that SELECT uid , current_location FROM user WHERE current_location = '115175415163151'
but I get the next error
"{
"error": {
"message": "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 ",
"type": "NoIndexFunctionException",
"code": 604
}
}"
Sadly you just cannot get User's location as it requires either user_location or friends_location , quoting from User documentation that means you just can't retrieve any User's location without User allowing you the required permission.
Secondly you cannot query on fql without using an indexable column in WHERE clause, quoting from fql documentation
Your query must also be indexable, meaning that it queries properties that are marked as indexable in the documentation below.

How Can I filter Facebook Events Using Location by FQL

How Can I fitler Facebook Events Using Location By FQL
ex. I want to get all event which will be in Egypt
SELECT name FROM event
WHERE strpos(lower(name), 'Egypt') >= 0
https://developers.facebook.com/tools/explorer?fql=SELECT%20name%0AFROM%20event%20%0AWHERE%20strpos%28lower%28name%29%2C%20%27Egypt%27%29%20%3E%3D%200
But when I try to use the above Query it returns that for me:
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
Note : I hope to get the public events filtered by event name contains.
With the changes that they have made, queries using an app access_token cannot
use the above query:
SELECT name,location FROM event WHERE contains('egypt')
The query works with session tokens (user access_tokens), however, with an app access_token
it just returns:
{
"error": {
"message": "(#200) Must have a valid access_token to access this endpoint",
"type": "OAuthException",
"code": 200
}
It was surprising to me since I could still use any other query else than contains on the events table with an app access_token
UPDATE:
After looking at their documentations, I found out that you can only use the app access token for very limited set of queries:
https://developers.facebook.com/docs/reference/api/search/
What I finally did was I used the following to obtain a session access_token from my user as a page_manager
https://www.facebook.com/dialog/oauth?client_id={MY_CLIENT_ID}&scope=manage_pages&redirect_uri={MY_REDIRECT_URI}&response_type=token
The above query returns your your access_token and you can use it to run your query successfully. What it basically does is that it appends your access_token to you as a hashed attributed
{MY_REDIRECT_URI}#access_token={MY_ACCESS_TOKEN}
If you would like to parse the access token on the server, this would not work for you, since the hashed attribute is not sent with the request to your server. What you can do is to append type=web_server to the above request to facebook. In that case the access_token will be returned as a request parameter named code
The closest you can get is to use the contains predicate
SELECT name,location FROM event WHERE contains('egypt')
Which will get you some events that contain "egypt" in the text