Example usage for org.springframework.social.facebook.connect FacebookConnectionFactory FacebookConnectionFactory

List of usage examples for org.springframework.social.facebook.connect FacebookConnectionFactory FacebookConnectionFactory

Introduction

In this page you can find the example usage for org.springframework.social.facebook.connect FacebookConnectionFactory FacebookConnectionFactory.

Prototype

public FacebookConnectionFactory(String appId, String appSecret) 

Source Link

Document

Creates a FacebookConnectionFactory for the given application ID and secret.

Usage

From source file:p2v.config.SocialConfig.java

@Bean
@Scope(value = "singleton", proxyMode = ScopedProxyMode.INTERFACES)
public ConnectionFactoryLocator connectionFactoryLocator() {
    ConnectionFactoryRegistry registry = new ConnectionFactoryRegistry();
    //             registry.addConnectionFactory(new TwitterConnectionFactory(environment.getProperty("twitter.consumerKey"),
    //                             environment.getProperty("twitter.consumerSecret")));
    registry.addConnectionFactory(new FacebookConnectionFactory(environment.getProperty("facebook.clientId"),
            environment.getProperty("facebook.clientSecret")));
    return registry;
}

From source file:com.searchbox.framework.config.SocialConfig.java

/**
 * Configures the connection factories for Facebook and Twitter.
 * /* ww  w . java 2s  . co  m*/
 * @param cfConfig
 * @param env
 */
@Override
public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, Environment env) {
    if (env.getProperty("twitter.consumer.key") != null && env.getProperty("twitter.consumer.secret") != null) {
        cfConfig.addConnectionFactory(new TwitterConnectionFactory(env.getProperty("twitter.consumer.key"),
                env.getProperty("twitter.consumer.secret")));
    }
    if (env.getProperty("facebook.app.id") != null && env.getProperty("facebook.app.secret") != null) {
        cfConfig.addConnectionFactory(new FacebookConnectionFactory(env.getProperty("facebook.app.id"),
                env.getProperty("facebook.app.secret")));
    }
}

From source file:org.fuzzydb.samples.mvc.config.SocialConfig.java

@Bean
@Scope(value = "singleton", proxyMode = ScopedProxyMode.INTERFACES)
public ConnectionFactoryLocator connectionFactoryLocator() {
    ConnectionFactoryRegistry registry = new ConnectionFactoryRegistry();
    registry.addConnectionFactory(new TwitterConnectionFactory(environment.getProperty("twitter.consumerKey"),
            environment.getProperty("twitter.consumerSecret")));
    registry.addConnectionFactory(new FacebookConnectionFactory(environment.getProperty("facebook.clientId"),
            environment.getProperty("facebook.clientSecret")));
    return registry;
}

From source file:ro.teamnet.hero.config.SocialConfig.java

@Override
public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, Environment env) {
    cfConfig.addConnectionFactory(new TwitterConnectionFactory(env.getProperty("twitter.consumerKey"),
            env.getProperty("twitter.consumerSecret")));
    cfConfig.addConnectionFactory(new FacebookConnectionFactory(env.getProperty("facebook.clientId"),
            env.getProperty("facebook.clientSecret")));
    cfConfig.addConnectionFactory(new LinkedInConnectionFactory(env.getProperty("linkedin.consumerKey"),
            env.getProperty("linkedin.consumerSecret")));
}

From source file:com.ssn.app.loader.SplashDemo.java

/**
 * @param args the command line arguments
 *//*from  ww w . j  av a  2  s  .co m*/
//public static void main(String[] args) {
public SplashDemo() {
    // TODO code application logic here
    logger.info("SplashDemo Start : ");
    splashInit(); // initialize splash overlay drawing parameters
    appInit(); // simulate what an application would do 
    // before starting
    HttpURLConnection conn = null;
    boolean isLoggedIn = SSNHelper.isLoggedInWithSocial();
    if (isLoggedIn) {
        Map<String, Object> map = SSNHelper.deserializeAccessToken();
        SSNLoginModel loginModel = new SSNLoginModel();
        if (map.keySet().contains("Facebook")) {
            AccessGrant accessGrant = (AccessGrant) map.get("Facebook");

            FacebookConnectionFactory connectionFactory = new FacebookConnectionFactory(
                    SSNConstants.SSN_FACEBOOK_API_KEY, SSNConstants.SSN_FACEBOOK_SECRET_KEY);
            Connection<Facebook> facebookConnection = connectionFactory.createConnection(accessGrant);
            Facebook facebook = facebookConnection.getApi();
            FacebookProfile userProfile = facebook.userOperations().getUserProfile();

            SSNSocialModel model = null;
            try {
                model = SSNDao.findUserByUsernname(userProfile.getName(), "Facebook");
            } catch (SQLException ex) {
                java.util.logging.Logger.getLogger(SplashDemo.class.getName()).log(Level.SEVERE, null, ex);
            }
            SSNLoginResponse loginResponse = loginModel.processSSNSocialLogin(userProfile.getFirstName(),
                    "Facebook", userProfile.getId() + "");

            SSNHomeForm homeForm = new SSNHomeForm(null, loginResponse, model, accessGrant, "Facebook");
            // homeForm.setFacebookAccessGrant(accessGrant);
        } else if (map.keySet().contains("Twitter")) {
            OAuthToken oAuthToken = (OAuthToken) map.get("Twitter");

            Twitter twitter = new TwitterTemplate(SSNConstants.SSN_TWITTER_API_KEY,
                    SSNConstants.SSN_TWITTER_SECRET_KEY, oAuthToken.getValue(), oAuthToken.getSecret());
            TwitterProfile userProfile = twitter.userOperations().getUserProfile();

            SSNSocialModel model = null;
            try {
                model = SSNDao.findUserByUsernname(twitter.userOperations().getScreenName(), "Twitter");
            } catch (SQLException ex) {
                java.util.logging.Logger.getLogger(SplashDemo.class.getName()).log(Level.SEVERE, null, ex);
            }
            SSNLoginResponse loginResponse = loginModel.processSSNSocialLogin(userProfile.getName(), "Twitter",
                    userProfile.getId() + "");

            SSNHomeForm homeForm = new SSNHomeForm(null, loginResponse, model, oAuthToken);
            // homeForm.setTwitterOAuthToken(oAuthToken);
        } else if (map.keySet().contains("Instagram")) {
            try {
                AccessGrant accessGrant = (AccessGrant) map.get("Instagram");

                URL url = new URL(String.format("https://api.instagram.com/v1/users/self?access_token=%s",
                        accessGrant.getAccessToken()));
                conn = (HttpURLConnection) url.openConnection();
                conn.setRequestMethod("GET");
                conn.setRequestProperty("Accept", "application/json");

                String username = "", fullName = "", id = "";
                if (conn.getResponseCode() == 200) {
                    StringBuilder builder = new StringBuilder();
                    BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));

                    String output;
                    while ((output = br.readLine()) != null) {
                        builder.append(output);
                    }

                    ObjectMapper mapper = new ObjectMapper();
                    Map<String, Object> outputJSON = mapper.readValue(builder.toString(), Map.class);

                    Map<String, Object> data = (Map<String, Object>) outputJSON.get("data");
                    username = (String) data.get("username");
                    fullName = (String) data.get("full_name");
                    id = (String) data.get("id");
                    br.close();
                }

                SSNSocialModel model = SSNDao.findUserByUsernname(username, "Instagram");
                SSNLoginResponse loginResponse = loginModel.processSSNSocialLogin(fullName, "Instagram", id);

                SSNHomeForm homeForm = new SSNHomeForm(null, loginResponse, model, accessGrant, "Instagram");
            } catch (IOException e) {
                logger.error(e.getMessage());

            } catch (SQLException ex) {
                java.util.logging.Logger.getLogger(SplashDemo.class.getName()).log(Level.SEVERE, null, ex);
            } finally {

            }
        }

    } else {
        new SSNLoginForm();
    }

    //new SSNSplashScreen(5000,750,477);  
    if (mySplash != null) // check if we really had a spash screen
    {
        if (mySplash.isVisible())
            mySplash.close(); // if so we're now done with it
    }
    // begin with the interactive portion of the program

}

From source file:com.kdubb.socialshowcaseboot.config.SocialConfig.java

@Override
public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, Environment env) {
    cfConfig.addConnectionFactory(new TwitterConnectionFactory(env.getProperty("twitter.appKey"),
            env.getProperty("twitter.appSecret")));
    cfConfig.addConnectionFactory(new FacebookConnectionFactory(env.getProperty("facebook.appKey"),
            env.getProperty("facebook.appSecret")));
    cfConfig.addConnectionFactory(new LinkedInConnectionFactory(env.getProperty("linkedin.appKey"),
            env.getProperty("linkedin.appSecret")));
}

From source file:org.easit.core.configurations.SocialConfig.java

/**
 * Registering the ASIT connections provided to social networks. This
 * process requires to gather private keys of the social services associated
 * to the application//  www . j  av a 2s  .  c  o m
 * 
 * @return
 */
@Bean
@Scope(value = "singleton", proxyMode = ScopedProxyMode.INTERFACES)
public ConnectionFactoryLocator connectionFactoryLocator() {
    //Handles the back-end side of the authorization flow
    ConnectionFactoryRegistry registry = new ConnectionFactoryRegistry();
    registry.addConnectionFactory(new TwitterConnectionFactory(environment.getProperty("twitter.consumerKey"),
            environment.getProperty("twitter.consumerSecret")));
    registry.addConnectionFactory(new FacebookConnectionFactory(environment.getProperty("facebook.clientId"),
            environment.getProperty("facebook.clientSecret")));
    return registry;
}

From source file:domain.user.social.SocialConfig.java

@Bean
@Scope(value = "singleton", proxyMode = ScopedProxyMode.INTERFACES)
public ConnectionFactoryLocator connectionFactoryLocator() {
    ConnectionFactoryRegistry registry = new ConnectionFactoryRegistry();
    registry.addConnectionFactory(new FacebookConnectionFactory(FB_APP_ID, FB_APP_SECRET));
    return registry;
}

From source file:info.bluefoot.winter.config.SocialConfig.java

@Override
public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, Environment env) {
    if (StringUtils.isBlank(twitterKey) || StringUtils.isBlank(facebookKey) || StringUtils.isBlank(googleKey)) {
        throw new IllegalStateException(
                "Can't find out social login provider keys based on environment variables");
    }//from   w w w  .  j  a  v  a2  s  .c  o m
    cfConfig.addConnectionFactory(new TwitterConnectionFactory(twitterKey, twitterSecret));
    cfConfig.addConnectionFactory(new FacebookConnectionFactory(facebookKey, facebookSecret));
    cfConfig.addConnectionFactory(new GoogleConnectionFactory(googleKey, googleSecret));
}

From source file:com.lixiaocong.social.SocialConfig.java

@Override
public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, Environment env) {
    cfConfig.addConnectionFactory(/* w  ww.jav a 2  s  .  co  m*/
            new QQConnectionFactory(env.getProperty("qq.id"), env.getProperty("qq.secret")));
    cfConfig.addConnectionFactory(
            new FacebookConnectionFactory(env.getProperty("facebook.id"), env.getProperty("facebook.secret")));
}