本文整理汇总了Java中org.springframework.social.twitter.connect.TwitterConnectionFactory类的典型用法代码示例。如果您正苦于以下问题:Java TwitterConnectionFactory类的具体用法?Java TwitterConnectionFactory怎么用?Java TwitterConnectionFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TwitterConnectionFactory类属于org.springframework.social.twitter.connect包,在下文中一共展示了TwitterConnectionFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addConnectionFactories
import org.springframework.social.twitter.connect.TwitterConnectionFactory; //导入依赖的package包/类
/**
* Configures the connection factories for Facebook and Twitter.
* @param cfConfig
* @param env
*/
@Override
public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, Environment env) {
cfConfig.addConnectionFactory(new TwitterConnectionFactory(
env.getProperty("twitter.consumer.key"),
env.getProperty("twitter.consumer.secret")
));
cfConfig.addConnectionFactory(new GoogleConnectionFactory(
env.getProperty("twitter.consumer.key"), //TODO !!!!!!!!!!
env.getProperty("twitter.consumer.secret") //TODO !!!!!!!!!!
));
FacebookConnectionFactory facebookFactory = new FacebookConnectionFactory(
env.getProperty("facebook.app.id"),
env.getProperty("facebook.app.secret"));
facebookFactory.setScope("public_profile,email,user_friends");
cfConfig.addConnectionFactory(facebookFactory);
}
示例2: printWelcome
import org.springframework.social.twitter.connect.TwitterConnectionFactory; //导入依赖的package包/类
@RequestMapping(value = "/twitterLogin")
public void printWelcome(HttpServletResponse response,HttpServletRequest request) {
TwitterConnectionFactory connectionFactoryTwitter =
new TwitterConnectionFactory("<consumer id>","<consumer key>");
OAuth1Operations oauth1Operations = connectionFactoryTwitter.getOAuthOperations();
OAuthToken requestToken = oauth1Operations.fetchRequestToken("http://www.localhost:8080/ch08/erp/twitterAuthentication.html", null);
String authorizeUrl = oauth1Operations.buildAuthorizeUrl(requestToken.getValue(), OAuth1Parameters.NONE);
try {
response.sendRedirect(authorizeUrl);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例3: callback
import org.springframework.social.twitter.connect.TwitterConnectionFactory; //导入依赖的package包/类
@RequestMapping(value = "/twitterAuthentication")
public RedirectView callback(@RequestParam(value = "oauth_token") String oauthToken, @RequestParam(value = "oauth_verifier") String oauthVerifier) {
TwitterConnectionFactory connectionFactoryTwitter =
new TwitterConnectionFactory("<consumer id>","<consumer key>");
OAuth1Operations oauth1Operations = connectionFactoryTwitter.getOAuthOperations();
OAuthToken requestToken = oauth1Operations.fetchRequestToken("http://www.localhost:8080/ch08/erp/twitterAuthentication.html", null);
RedirectView redirectView = new RedirectView();
redirectView.setContextRelative(true);
OAuthToken accessToken = oauth1Operations.exchangeForAccessToken(new AuthorizedRequestToken(requestToken, oauthVerifier), OAuth1Parameters.NONE);
if(accessToken.equals("<enter access token here>")){
redirectView.setUrl("/erp/paymentmodes.xml");
}else{
redirectView.setUrl("http://www.google.com");
}
return redirectView;
}
示例4: createConnectionFactory
import org.springframework.social.twitter.connect.TwitterConnectionFactory; //导入依赖的package包/类
public ConnectionFactory<?> createConnectionFactory(String appId, String appSecret) {
switch(this) {
case facebook:
return new FacebookConnectionFactory(appId, appSecret);
case twitter:
return new TwitterConnectionFactory(appId, appSecret);
case google:
GoogleConnectionFactory factory = new GoogleConnectionFactory(appId, appSecret);
factory.setScope("openid profile");
return factory;
case linkedin:
return new LinkedInConnectionFactory(appId, appSecret);
case github:
return new GitHubConnectionFactory(appId, appSecret);
default:
return null;
}
}
示例5: addConnectionFactories
import org.springframework.social.twitter.connect.TwitterConnectionFactory; //导入依赖的package包/类
@Override
public void addConnectionFactories(ConnectionFactoryConfigurer configurer,
Environment env) {
final FacebookConnectionFactory facebook = new FacebookConnectionFactory(
env.getRequiredProperty("spring.social.facebook.appId"),
env.getRequiredProperty("spring.social.facebook.appSecret"));
facebook.setScope(EMAIL);
final TwitterConnectionFactory twitter = new TwitterConnectionFactory(
env.getRequiredProperty("spring.social.twitter.appId"),
env.getRequiredProperty("spring.social.twitter.appSecret"));
final GoogleConnectionFactory google = new GoogleConnectionFactory(
env.getRequiredProperty("spring.social.google.appId"),
env.getRequiredProperty("spring.social.google.appSecret"));
google.setScope(EMAIL);
configurer.addConnectionFactory(facebook);
configurer.addConnectionFactory(google);
configurer.addConnectionFactory(twitter);
}
示例6: addConnectionFactories
import org.springframework.social.twitter.connect.TwitterConnectionFactory; //导入依赖的package包/类
@Override
public void addConnectionFactories(ConnectionFactoryConfigurer connectionFactoryConfigurer, Environment environment) {
connectionFactoryConfigurer.addConnectionFactory(new FacebookConnectionFactory(
environment.getProperty("spring.social.facebook.appId"),
environment.getProperty("spring.social.facebook.appSecret")));
connectionFactoryConfigurer.addConnectionFactory(new TwitterConnectionFactory(
environment.getProperty("twitter.consumerKey"),
environment.getProperty("twitter.consumerSecret")));
connectionFactoryConfigurer.addConnectionFactory(new LinkedInConnectionFactory(
environment.getProperty("spring.social.linkedin.appId"),
environment.getProperty("spring.social.linkedin.appSecret")));
connectionFactoryConfigurer.addConnectionFactory(new GoogleConnectionFactory(
environment.getProperty("spring.social.google.appId"),
environment.getProperty("spring.social.google.appSecret")));
connectionFactoryConfigurer.addConnectionFactory(new GitHubConnectionFactory(
environment.getProperty("spring.social.github.appId"),
environment.getProperty("spring.social.github.appSecret")));
connectionFactoryConfigurer.addConnectionFactory(new LiveConnectionFactory(
environment.getProperty("spring.social.live.appId"),
environment.getProperty("spring.social.live.appSecret")));
}
示例7: createCredentialProvider
import org.springframework.social.twitter.connect.TwitterConnectionFactory; //导入依赖的package包/类
static CredentialProvider createCredentialProvider(final SocialProperties properties) {
final TwitterConnectionFactory twitter = new TwitterConnectionFactory(properties.getAppId(),
properties.getAppSecret());
final OAuth1Applicator applicator = new OAuth1Applicator(properties);
applicator.setConsumerKeyProperty("consumerKey");
applicator.setConsumerSecretProperty("consumerSecret");
applicator.setAccessTokenSecretProperty("accessTokenSecret");
applicator.setAccessTokenValueProperty("accessToken");
return new OAuth1CredentialProvider<>("twitter", twitter, applicator);
}
示例8: addConnectionFactories
import org.springframework.social.twitter.connect.TwitterConnectionFactory; //导入依赖的package包/类
@Override
public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, Environment env) {
cfConfig.addConnectionFactory(new TwitterConnectionFactory(appSettings.getTwitterAppId(),
appSettings.getTwitterAppSecret()));
cfConfig.addConnectionFactory(new FacebookConnectionFactory(appSettings.getFacebookAppId(),
appSettings.getFacebookAppSecret()));
cfConfig.addConnectionFactory(new GoogleConnectionFactory(appSettings.getGoogleAppId(),
appSettings.getGoogleAppSecret()));
}
示例9: connectionFactoryLocator
import org.springframework.social.twitter.connect.TwitterConnectionFactory; //导入依赖的package包/类
@Bean
@Scope(value = "singleton", proxyMode = ScopedProxyMode.INTERFACES)
public ConnectionFactoryLocator connectionFactoryLocator() {
ConnectionFactoryRegistry registry = new ConnectionFactoryRegistry();
final GoogleConnectionFactory gcf = new GoogleConnectionFactory(
environment.getProperty("google.consumerKey"),
environment.getProperty("google.consumerSecret"));
registry.addConnectionFactory(gcf);
final TwitterConnectionFactory tcf = new TwitterConnectionFactory
(environment.getProperty("twitter.consumerKey"),
environment.getProperty("twitter.consumerSecret"));
registry.addConnectionFactory(tcf);
return registry;
}
示例10: connectionFactoryLocator
import org.springframework.social.twitter.connect.TwitterConnectionFactory; //导入依赖的package包/类
@Bean
public ConnectionFactoryLocator connectionFactoryLocator() {
ConnectionFactoryRegistry registry = new ConnectionFactoryRegistry();
registry.addConnectionFactory(new FacebookConnectionFactory(config.getFacebookClientId(),
config.getFacebookClientSecrect()));
registry.addConnectionFactory(new TwitterConnectionFactory(config.getTwitterClientId(),
config.getTwitterClientSecret()));
return registry;
}
示例11: connectionFactoryLocator
import org.springframework.social.twitter.connect.TwitterConnectionFactory; //导入依赖的package包/类
/**
* The locator for SaaS provider connection factories.
* When support for a new provider is added to Greenhouse, simply register the corresponding {@link ConnectionFactory} here.
* The current Environment is used to lookup the credentials assigned to the Greenhouse application by each provider during application registration.
* This bean is defined as a scoped-proxy so it can be serialized in support of {@link ProviderSignInAttempt provier sign-in attempts}.
*/
@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.appId"), environment.getProperty("facebook.appSecret")));
registry.addConnectionFactory(new LinkedInConnectionFactory(environment.getProperty("linkedin.consumerKey"), environment.getProperty("linkedin.consumerSecret")));
registry.addConnectionFactory(new TripItConnectionFactory(environment.getProperty("tripit.consumerKey"), environment.getProperty("tripit.consumerSecret")));
return registry;
}
示例12: connectionFactoryLocator
import org.springframework.social.twitter.connect.TwitterConnectionFactory; //导入依赖的package包/类
@Bean
public ConnectionFactoryLocator connectionFactoryLocator() {
ConnectionFactoryRegistry registry = new ConnectionFactoryRegistry();
registry.addConnectionFactory(new FacebookConnectionFactory(facebookClientId,
facebookSecret));
registry.addConnectionFactory(new TwitterConnectionFactory(twitterConsumerKey,
twitterConsumerSecret));
return registry;
}
示例13: addConnectionFactories
import org.springframework.social.twitter.connect.TwitterConnectionFactory; //导入依赖的package包/类
@Override
public void addConnectionFactories(ConnectionFactoryConfigurer connectionFactoryConfigurer, Environment environment) {
// Google configuration
String googleClientId = environment.getProperty("spring.social.google.client-id");
String googleClientSecret = environment.getProperty("spring.social.google.client-secret");
if (googleClientId != null && googleClientSecret != null) {
log.debug("Configuring GoogleConnectionFactory");
connectionFactoryConfigurer.addConnectionFactory(
new GoogleConnectionFactory(
googleClientId,
googleClientSecret
)
);
} else {
log.error("Cannot configure GoogleConnectionFactory id or secret null");
}
// Facebook configuration
String facebookClientId = environment.getProperty("spring.social.facebook.client-id");
String facebookClientSecret = environment.getProperty("spring.social.facebook.client-secret");
if (facebookClientId != null && facebookClientSecret != null) {
log.debug("Configuring FacebookConnectionFactory");
connectionFactoryConfigurer.addConnectionFactory(
new FacebookConnectionFactory(
facebookClientId,
facebookClientSecret
)
);
} else {
log.error("Cannot configure FacebookConnectionFactory id or secret null");
}
// Twitter configuration
String twitterClientId = environment.getProperty("spring.social.twitter.client-id");
String twitterClientSecret = environment.getProperty("spring.social.twitter.client-secret");
if (twitterClientId != null && twitterClientSecret != null) {
log.debug("Configuring TwitterConnectionFactory");
connectionFactoryConfigurer.addConnectionFactory(
new TwitterConnectionFactory(
twitterClientId,
twitterClientSecret
)
);
} else {
log.error("Cannot configure TwitterConnectionFactory id or secret null");
}
// jhipster-needle-add-social-connection-factory
}
示例14: addConnectionFactories
import org.springframework.social.twitter.connect.TwitterConnectionFactory; //导入依赖的package包/类
@Override
public void addConnectionFactories(ConnectionFactoryConfigurer connectionFactoryConfigurer, Environment environment) {
// Google configuration
String googleClientId = environment.getProperty("spring.social.google.clientId");
String googleClientSecret = environment.getProperty("spring.social.google.clientSecret");
if (googleClientId != null && googleClientSecret != null) {
log.debug("Configuring GoogleConnectionFactory");
connectionFactoryConfigurer.addConnectionFactory(
new GoogleConnectionFactory(
googleClientId,
googleClientSecret
)
);
} else {
log.error("Cannot configure GoogleConnectionFactory id or secret null");
}
// Facebook configuration
String facebookClientId = environment.getProperty("spring.social.facebook.clientId");
String facebookClientSecret = environment.getProperty("spring.social.facebook.clientSecret");
if (facebookClientId != null && facebookClientSecret != null) {
log.debug("Configuring FacebookConnectionFactory");
connectionFactoryConfigurer.addConnectionFactory(
new FacebookConnectionFactory(
facebookClientId,
facebookClientSecret
)
);
} else {
log.error("Cannot configure FacebookConnectionFactory id or secret null");
}
// Twitter configuration
String twitterClientId = environment.getProperty("spring.social.twitter.clientId");
String twitterClientSecret = environment.getProperty("spring.social.twitter.clientSecret");
if (twitterClientId != null && twitterClientSecret != null) {
log.debug("Configuring TwitterConnectionFactory");
connectionFactoryConfigurer.addConnectionFactory(
new TwitterConnectionFactory(
twitterClientId,
twitterClientSecret
)
);
} else {
log.error("Cannot configure TwitterConnectionFactory id or secret null");
}
}
示例15: addConnectionFactories
import org.springframework.social.twitter.connect.TwitterConnectionFactory; //导入依赖的package包/类
@Override
public void addConnectionFactories(ConnectionFactoryConfigurer connectionFactoryConfigurer, Environment environment) {
// Google configuration
String googleClientId = environment.getProperty("spring.social.google.clientId");
String googleClientSecret = environment.getProperty("spring.social.google.clientSecret");
if (googleClientId != null && googleClientSecret != null) {
log.debug("Configuring GoogleConnectionFactory");
connectionFactoryConfigurer.addConnectionFactory(
new GoogleConnectionFactory(
googleClientId,
googleClientSecret
)
);
} else {
log.error("Cannot configure GoogleConnectionFactory id or secret null");
}
// Facebook configuration
String facebookClientId = environment.getProperty("spring.social.facebook.clientId");
String facebookClientSecret = environment.getProperty("spring.social.facebook.clientSecret");
if (facebookClientId != null && facebookClientSecret != null) {
log.debug("Configuring FacebookConnectionFactory");
connectionFactoryConfigurer.addConnectionFactory(
new FacebookConnectionFactory(
facebookClientId,
facebookClientSecret
)
);
} else {
log.error("Cannot configure FacebookConnectionFactory id or secret null");
}
// Twitter configuration
String twitterClientId = environment.getProperty("spring.social.twitter.clientId");
String twitterClientSecret = environment.getProperty("spring.social.twitter.clientSecret");
if (twitterClientId != null && twitterClientSecret != null) {
log.debug("Configuring TwitterConnectionFactory");
connectionFactoryConfigurer.addConnectionFactory(
new TwitterConnectionFactory(
twitterClientId,
twitterClientSecret
)
);
} else {
log.error("Cannot configure TwitterConnectionFactory id or secret null");
}
// jhipster-needle-add-social-connection-factory
}