private FacebookClient.AccessToken getFacebookUserToken(String code, String redirectUrl) throws IOException { String appId = "YOUR_APP_ID"; String secretKey = "YOUR_SECRET_KEY"; WebRequestor wr = new DefaultWebRequestor(); WebRequestor.Response accessTokenResponse = wr.executeGet( "https://graph.facebook.com/oauth/access_token?client_id=" + appId + "&redirect_uri=" + redirectUrl + "&client_secret=" + secretKey + "&code=" + code); return DefaultFacebookClient.AccessToken.fromQueryString(accessTokenResponse.getBody()); }
/** * Creates a Facebook Graph API client with the given {@code accessToken}. * * @param accessToken * A Facebook OAuth access token. * @param apiVersion * Version of the api endpoint * @since 1.6.14 */ public DefaultFacebookClient(String accessToken, Version apiVersion) { this(accessToken, null, new DefaultWebRequestor(), new DefaultJsonMapper(), apiVersion); }
/** * Creates a Facebook Graph API client with the given {@code apiVersion}. * * @param apiVersion * Version of the api endpoint */ public DefaultFacebookClient(Version apiVersion) { this(null, null, new DefaultWebRequestor(), new DefaultJsonMapper(), apiVersion); }
/** * Creates a Facebook API client with the given <a * href="http://developers.facebook.com/docs/guides/upgrade#oauth">OAuth * access token</a>. * * @param accessToken An OAuth access token. * @throws NullPointerException If {@code accessToken} is {@code null}. * @throws IllegalArgumentException If {@code accessToken} is a blank string. * @since 1.5 */ public DefaultLegacyFacebookClient(String accessToken) { this(accessToken, new DefaultWebRequestor(), new DefaultJsonMapper()); }
/** * Creates a Facebook Graph API client with the given {@code accessToken}. * * @param accessToken A Facebook OAuth access token. */ public DefaultFacebookClient(String accessToken) { this(accessToken, new DefaultWebRequestor(), new DefaultJsonMapper()); }
/** * Creates a Facebook Graph API client with the given {@code accessToken}. * * @param accessToken * A Facebook OAuth access token. * @param appSecret * A Facebook application secret. * @param apiVersion * Version of the api endpoint * @since 1.6.14 */ public DefaultFacebookClient(String accessToken, String appSecret, Version apiVersion) { this(accessToken, appSecret, new DefaultWebRequestor(), new DefaultJsonMapper(), apiVersion); }
/** * Creates a Facebook API client with the given API key and secret key (Legacy * authentication). * * @param apiKey A Facebook API key. * @param secretKey A Facebook application secret key. * @throws NullPointerException If either parameter is {@code null}. * @throws IllegalArgumentException If either parameter is a blank string. * @deprecated You should use {@link #DefaultLegacyFacebookClient(String)} * instead. Facebook is moving to OAuth and will stop supporting * the old authentication scheme soon. */ @Deprecated public DefaultLegacyFacebookClient(String apiKey, String secretKey) { this(apiKey, secretKey, new DefaultWebRequestor(), new DefaultJsonMapper()); }
/** * Ctor. * @param fapp Facebook app * @param fkey Facebook key */ public PsFacebook(final String fapp, final String fkey) { this( new JdkRequest( new Href(PsFacebook.ACCESS_TOKEN_URL) .with(PsFacebook.CLIENT_ID, fapp) .with(PsFacebook.CLIENT_SECRET, fkey) .toString() ), new DefaultWebRequestor(), fapp, fkey ); }
/** * Ctor. * @param fapp Facebook app * @param fkey Facebook key */ public PsFacebook(final String fapp, final String fkey) { this( new JdkRequest( new Href(PsFacebook.ACCESS_TOKEN_URL) .with(PsFacebook.CLIENT_ID, fapp) .with(PsFacebook.CLIENT_SECRET, fkey) .toString() ), new DefaultWebRequestor(), fapp, fkey ); }