I am writing a small app that after logging a user into Facebook, runs a query and displays the result in the console, and I am running into problems:
First, I do the login-thing:
FB.Event.subscribe('auth.authResponseChange', function(response) {
if (response.status === 'connected') {
var accesstoken=response;
getSomeEvents(accesstoken);
} else if (response.status === 'not_authorized') {
FB.login(function(response){
}, {scope: 'email,user_likes, user_events, friends_events'});
} else {
FB.login(function(response){
}, {scope: 'email,user_likes, user_events, friends_events'});
}
});
};
Then, I try to query FB, with the Graph API. Below, I am simplifying the query to make my problem clearer
function getSomeEvents(accesstoken){
var query2=encodeURI("SELECT name, eid, venue, location FROM event WHERE eid=364689750343572 & access_token="+accesstoken.authResponse.accessToken);
//Method 1: Querying with the graph API
FB.api('/fql?q='+query2, function(events) {
console.log('In Method 1 - Updated Graph API - event-name is ' + events.name + '.');
});
}
The chrome debugger gives me this: "Your statement is not indexable. The WHERE clause must contain an indexable column. Such columns are marked with * in the tables linked from..."
However, EID is indexable according to this: https://developers.facebook.com/docs/reference/fql/event
Moreover, if I replace the query with what I am actually trying to do:
var query2=encodeURI("SELECT name, eid, venue, location FROM event WHERE eid in ( SELECT eid FROM event_member WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) ) limit 100 & access_token="+accesstoken.authResponse.accessToken);
I get this in the chrome debugger: "(#601) Parser error: unexpected end of query."; type: OAuthException
Both queries work in Facebooks Graph API console, and return data when typed directly into the browser as GET-requests (http://graph.facebook.com/fql?q=).
Any ideas as to what I am doing wrong?
You do not need the accesstoken to get the details of an event.
I don't know why you seem to be getting this problem, I assume its an encoding error. Anyway this works:
Remember the results are returned under response.data, and those results are an array.
PS you can get event info directly without using FQL:
Source: https://developers.facebook.com/docs/reference/javascript/FB.api/