Package facebook4j

Examples of facebook4j.FacebookFactory


public class SignInServlet extends HttpServlet {
    private static final long serialVersionUID = -7453606094644144082L;

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Facebook facebook = new FacebookFactory().getInstance();
        request.getSession().setAttribute("facebook", facebook);
        StringBuffer callbackURL = request.getRequestURL();
        int index = callbackURL.lastIndexOf("/");
        callbackURL.replace(index, callbackURL.length(), "").append("/callback");
        response.sendRedirect(facebook.getOAuthAuthorizationURL(callbackURL.toString()));
View Full Code Here


public class OAuthController extends BaseController {

    @Override
    protected Navigation execute(UserModel loginUserModel) throws Exception {

        Facebook facebook = new FacebookFactory().getInstance();
        facebook.setOAuthAppId(Constants.FACEBOOK_APP_API_KEY, Constants.FACEBOOK_APP_API_SECRET);
        facebook.setOAuthPermissions(Constants.FACEBOOK_APP_API_PERMISSIONS);
        sessionScope("facebook", facebook);

View Full Code Here

     * @param msg
     * @return
     */
    private Facebook getFaceBookObject(UserModel userModel) throws Exception {

        Facebook facebook = new FacebookFactory().getInstance();
        facebook.setOAuthAppId(Constants.FACEBOOK_APP_API_KEY, Constants.FACEBOOK_APP_API_SECRET);
        facebook.setOAuthPermissions(Constants.FACEBOOK_APP_API_PERMISSIONS);
        facebook.setOAuthAccessToken(new AccessToken(userModel.getFacebookAccessTokenString()));

        return facebook;
View Full Code Here

     * @return {@link Facebook} instance
     */
    public Facebook getFacebook() throws FacebookException {
        if (facebook == null) {
            final Configuration configuration = getConfiguration();
            FacebookFactory factory = new FacebookFactory(configuration);
            if (this.oAuthAccessToken == null) {
                // app login
                facebook = factory.getInstance(new OAuthAuthorization(configuration));
                // also get the App access token
                facebook.getOAuthAppAccessToken();
                LOG.warn("Login with app id and secret, access to some APIs is restricted!");
            } else {
                // user login with token
                facebook = factory.getInstance();
                // verify the access token
                facebook.getOAuthAccessToken();
                LOG.debug("Login with app id, secret and token, all APIs accessible");
            }
        }
View Full Code Here

    @Test
    public void deterministic() throws Exception {
        ArrayList list1 = new ArrayList();
        ArrayList list2 = new ArrayList();
        assertThat(list1, is(list2));
        Facebook Facebook1 = new FacebookFactory().getInstance();
        Facebook1.setOAuthAppId("appId", "appSecret");
        Facebook Facebook2 = new FacebookFactory().getInstance();
        Facebook2.setOAuthAppId("appId", "appSecret");
        assertThat(Facebook1, is(Facebook2));
    }
View Full Code Here

        String oAuthAppSecret = p.getProperty("oauth.appSecret");
        build.setOAuthAccessToken(oAuthAccessToken);
        build.setOAuthAppId(oAuthAppId);
        build.setOAuthAppSecret(oAuthAppSecret);
        OAuthAuthorization auth = new OAuthAuthorization(build.build());
        Facebook fb = new FacebookFactory().getInstance(auth);
        fb.getId();
    }
View Full Code Here

    @Category(RealAPITests.class)
    @Test
    public void signinWithFacebook() throws Exception {
        CookieHandler.setDefault(new ListCookieHandler());

        Facebook facebook = new FacebookFactory().getInstance();
        HttpClientImpl http = new HttpClientImpl();
        HttpResponse response;
       
        String oAuthAppId = p.getProperty("oauth.appId");
        String oAuthAppSecret = p.getProperty("oauth.appSecret");
View Full Code Here

        assertThat(redirectURL.contains("code"), is(true));
    }

    @Test(expected = IllegalStateException.class)
    public void illegalStatus() throws Exception {
        new FacebookFactory().getInstance().getOAuthAccessToken();
    }
View Full Code Here

public class AuthorizationTest extends FacebookTestBase {

    @Test
    public void anonymousInstance() throws Exception {
        Facebook facebook = new FacebookFactory().getInstance();
        Authorization auth = facebook.getAuthorization();
        assertThat(auth, instanceOf(NullAuthorization.class));
    }
View Full Code Here

        String appSecret;
        String appId;
        appSecret = p.getProperty("oauth.appSecret");
        appId = p.getProperty("oauth.appSecret");

        Facebook facebook = new FacebookFactory().getInstance();
        facebook.setOAuthAppId(appId, appSecret);
        try {
            facebook.setOAuthAppId(appSecret, appId);
            fail("should throw IllegalStateException");
        } catch (IllegalStateException ignore) {}
View Full Code Here

TOP

Related Classes of facebook4j.FacebookFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.