IT Certificaions

Google Cloud Platform

Tuesday, December 13, 2011

Executing FQL Queries :: FacebookResponseStatusException


com.restfb.exception.FacebookResponseStatusException: Received Facebook error response (code 601): Parser error: SELECT * is not supported.  Please manually list the columns you are interested in.
com.restfb.BaseFacebookClient$DefaultLegacyFacebookExceptionMapper.exceptionForTypeAndMessage(BaseFacebookClient.java:147)
com.restfb.BaseFacebookClient.throwLegacyFacebookResponseStatusExceptionIfNecessary(BaseFacebookClient.java:208)
com.restfb.DefaultFacebookClient.throwFacebookResponseStatusExceptionIfNecessary(DefaultFacebookClient.java:523)
com.restfb.DefaultFacebookClient.makeRequestAndProcessResponse(DefaultFacebookClient.java:485)
com.restfb.DefaultFacebookClient.makeRequest(DefaultFacebookClient.java:445)
com.restfb.DefaultFacebookClient.executeQuery(DefaultFacebookClient.java:366)
com.vicwalks.web.util.SocialMediaUtil.findFacebookFriendsUsingRest(SocialMediaUtil.java:84)
com.vicwalks.web.action.FacebookConnectAction.execute(FacebookConnectAction.java:87)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)



Solution: You can use SELECT * FROM ... here to fetch User class data on the basis of id.

Please use the column name that you want to fetch, see User class:

id,  name,  about, bio, birthday, email, firstName, lastName, gender, location  etc........


String query = "SELECT uid, name FROM user WHERE uid=220439 or uid=7901103";
List<FqlUser> users = facebookClient.executeQuery(query, FqlUser.class);


System.out.println("Users: " + users);

...

// Be aware that FQL fields don't always map to Graph API Object fields.

public class FqlUser {
  @Facebook
  String uid;
  
  @Facebook
  String name;


  @Override
  public String toString() {
    return String.format("%s (%s)", name, uid);
  }
}

===> For more, visit the RESTFB API