Question

I am using facebook4j i have set the configuartion details in facebook4j.properties file. But when i trying to get the accesstoken it shows

SEVERE: Error while creating the Access TokenOAuth app id/secret combination not supplied
java.lang.IllegalStateException: OAuth app id/secret combination not supplied
    at facebook4j.FacebookBaseImpl.getOAuth(FacebookBaseImpl.java:247)
    at facebook4j.FacebookBaseImpl.getOAuthAuthorizationURL(FacebookBaseImpl.java:213)
    at facebook4j.FacebookBaseImpl.getOAuthAuthorizationURL(FacebookBaseImpl.java:206)

Could anyone can provide a example for the facebook4j for java console application

Facebook facebookClient = new FacebookFactory().getInstance();
        return facebookClient;

No correct solution

OTHER TIPS

This is how you could use facebook4j without external configuration files. The code below provides a minimal example. Here is my simple demo:

import facebook4j.Facebook;
import facebook4j.FacebookException;
import facebook4j.FacebookFactory;
import facebook4j.auth.AccessToken;

public class Facebook4JMinimalExample {

/**
 * A simple Facebook4J client.
 * 
 * 
 * @param args
 * @throws FacebookException 
 */
public static void main(String[] args) throws FacebookException {

    // Generate facebook instance.
    Facebook facebook = new FacebookFactory().getInstance();
    // Use default values for oauth app id.
    facebook.setOAuthAppId("", "");
    // Get an access token from: 
    // https://developers.facebook.com/tools/explorer
    // Copy and paste it below.
    String accessTokenString = "PASTE_YOUR_ACCESS_TOKEN_STRING_HERE";
    AccessToken at = new AccessToken(accessTokenString);
    // Set access token.
    facebook.setOAuthAccessToken(at);

    // We're done.
    // Write some stuff to your wall.
    facebook.postStatusMessage("Wow, it works...");

}
}

Note that it is important to FIRST make a call to "facebook.setOAuthAppId(..)" and THEN set the access token. Otherwise you'll get an IllegalStateException saying "OAuth app id/secret combination not supplied".

In this case, I've just used a default value for OAuthAppId.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top