Facebook with RestFB (Java)
- by Trick
I just began to use this and I already stumbled on some from-my-side-strange errors.
I am using RestFB jar.
My problem is, that I can not get my session key (this is the start of everything :)).
FacebookClient facebookClient = new DefaultFacebookClient(API_KEY, SECRET_KEY);
try {
String token = facebookClient.execute("auth.createToken", String.class, Parameter.with("null", "null"));
System.out.println(token);
String session = facebookClient.execute("auth.getSession", String.class, Parameter.with("auth_token", token));
System.out.println(session);
} catch (FacebookException e) {
e.printStackTrace();
}
I get the token correctly. Parameter.with("null,"null") is there because it demands at least one, but method for creating token doesn't expect any.
When trying to get the session key, I get the following error:
com.restfb.FacebookResponseStatusException: Received Facebook error response (code 100): Invalid parameter
at com.restfb.DefaultFacebookClient.throwFacebookResponseStatusExceptionIfNecessary(DefaultFacebookClient.java:357)
at com.restfb.DefaultFacebookClient.makeRequest(DefaultFacebookClient.java:320)
at com.restfb.DefaultFacebookClient.execute(DefaultFacebookClient.java:188)
at com.restfb.DefaultFacebookClient.execute(DefaultFacebookClient.java:178)
Documentation for getting session doesn't say any more parameters are required!
Did anybody already try this JAR or do you have any other solution for Java?
EDIT:
Does the application needs to be "published" in searchers to be able to do this??