本文整理汇总了Java中facebook4j.conf.ConfigurationBuilder类的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationBuilder类的具体用法?Java ConfigurationBuilder怎么用?Java ConfigurationBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConfigurationBuilder类属于facebook4j.conf包,在下文中一共展示了ConfigurationBuilder类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: connect
import facebook4j.conf.ConfigurationBuilder; //导入依赖的package包/类
public void connect() throws FacebookException {
initProperties();
ConfigurationBuilder config = new ConfigurationBuilder();
String key = getOauthKey();
String secret = getOauthSecret();
if (this.appOauthKey != null && !this.appOauthKey.isEmpty()) {
key = this.appOauthKey;
}
if (this.appOauthSecret != null && !this.appOauthSecret.isEmpty()) {
secret = this.appOauthSecret;
}
config.setOAuthAppId(key);
config.setOAuthAppSecret(secret);
config.setOAuthAccessToken(getToken());
facebook4j.Facebook facebook = new FacebookFactory(config.build()).getInstance();
setConnection(facebook);
}
开发者ID:BotLibre,项目名称:BotLibre,代码行数:18,代码来源:Facebook.java
示例2: getNewToken
import facebook4j.conf.ConfigurationBuilder; //导入依赖的package包/类
/**
*
* @param accessType
* @return
*/
public static String getNewToken(String accessType){
logger.info("creando nuevo token");
ConfigurationBuilder cb = Configuration.getFacebookConfig();
facebook4j.conf.Configuration config = cb.build();
String oathAppId = config.getOAuthAppId();
String oathAppSecret = config.getOAuthAppSecret();
String oauthUrl = config.getOAuthAccessTokenURL();
String oldToken = config.getOAuthAccessToken();
oauthUrl += "?grant_type=fb_exchange_token";
oauthUrl += "&client_id="+oathAppId;
oauthUrl += "&client_secret="+oathAppSecret;
oauthUrl += "&fb_exchange_token="+oldToken;
logger.info("oathAppId:"+oathAppId);
logger.info("oathAppSecret:"+oathAppSecret);
logger.info("token URL:"+ oauthUrl);
try {
return getRawFacebookCall(oauthUrl, accessType);
} catch (Exception ex) {
logger.error(ex.getMessage(),ex);
return "";
}
}
开发者ID:developersdo,项目名称:developer-influencers,代码行数:31,代码来源:Oauth.java
示例3: initFacebook
import facebook4j.conf.ConfigurationBuilder; //导入依赖的package包/类
/**
* Initializes the facebook4j client.
*
* @param req the http request
* @return initialized facebook4j client
*/
private static Facebook initFacebook(HttpServletRequest req) {
if (facebook == null) {
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setJSONStoreEnabled(true);
FacebookFactory ff = new FacebookFactory(cb.build());
facebook = ff.getInstance();
}
try {
facebook.setOAuthAppId(Tokenmanager.getSocialToken(req).get("fbappid"), Tokenmanager.getSocialToken(req).get("fbappsecret"));
} catch (IllegalStateException | IOException | NullPointerException e) {
// macht nix
}
return facebook;
}
开发者ID:slauber,项目名称:Crawcial,代码行数:21,代码来源:FbServlet.java
示例4: reconnect
import facebook4j.conf.ConfigurationBuilder; //导入依赖的package包/类
@Override
public boolean reconnect() {
boolean result = false;
final String appId = CustomPortalServiceHandler
.getConfigValue(E_ConfigKey.SOCIAL_FB_APPID);
final String appSec = CustomPortalServiceHandler
.getConfigValue(E_ConfigKey.SOCIAL_FB_APPSEC);
final String aToken = CustomPortalServiceHandler
.getConfigValue(E_ConfigKey.SOCIAL_FB_AT);
if (appId != null && aToken != null && appSec != null
&& appId.trim().length() > 0 && aToken.trim().length() > 0
&& appSec.trim().length() > 0) {
final ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthAppId(appId)
.setOAuthAppSecret(appSec)
.setOAuthAccessToken(aToken)
.setOAuthPermissions("publish_stream");
final FacebookFactory ff = new FacebookFactory(cb.build());
this.m_objClient = ff.getInstance();
try {
this.m_objClient.getStatuses();
result = true;
this.m_bConnected = true;
} catch (final FacebookException e) {
m_objLog.warn(e);
}
}
return result;
}
开发者ID:fraunhoferfokus,项目名称:particity,代码行数:35,代码来源:FacebookClient.java
示例5: getFacebookInstance
import facebook4j.conf.ConfigurationBuilder; //导入依赖的package包/类
private static Facebook getFacebookInstance(String accessToken) {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.setDebugEnabled(false)
.setOAuthAppId(configProperties.getProperty(CollectorConfigurationProperty.FACEBOOK_CONSUMER_KEY))
.setOAuthAppSecret(
configProperties.getProperty(CollectorConfigurationProperty.FACEBOOK_CONSUMER_SECRET))
.setJSONStoreEnabled(true).setOAuthAccessToken(accessToken);
Configuration configuration = builder.build();
Facebook instance = new FacebookFactory(configuration).getInstance();
return instance;
}
开发者ID:qcri-social,项目名称:AIDR,代码行数:14,代码来源:FacebookFeedTracker.java
示例6: main
import facebook4j.conf.ConfigurationBuilder; //导入依赖的package包/类
public static void main(String[] args) {
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthAppId("1428624607431156")
.setOAuthAppSecret("9de584c1319b8cb6335c09f7d04d5153")
.setOAuthAccessToken(
"CAAUTU5YZBSfQBAIUixEZBa3PQLJo7"
+ "ikwXja7YVfVZBYyHd03JN2x10b335wJQTVMZBxV8KpT"
+ "j4lHWM9zuM3xrESYwdpXmkwS0KmXKdYxwMm1LZBCQrK"
+ "vdx7T6ohP3rFdJVu2ui6zSiLk3A0ZCQqe74PbcyER80"
+ "cfxGlWeFWyN6i6B4yzI0ZBXPl62IVkOJkzGoxnBblZA"
+ "iejFrszbLaLf8Eq")
.setOAuthPermissions("email, publish_stream, read_stream");
FacebookFactory ff = new FacebookFactory(cb.build());
Facebook facebook = ff.getInstance();
try {
/*ResponseList<Post> postResults = facebook.searchPosts("Food");*/
/*
ResponseList<User> userResults = facebook.searchUsers("Bryden Cho");
for(User u : userResults) {
if(u.getName().equalsIgnoreCase("Bryden Cho")) {
System.out.println(u.getId());
System.out.println(u.getName());
System.out.println();
}
}*/
/*ResponseList<Event> eventResults = facebook.searchEvents("Food");
for(Event e : eventResults) {
System.out.println(e.getId());
System.out.println(e.getName());
System.out.println(e.getLocation());
System.out.println();
}*/
ResponseList<Group> groupResults = facebook.searchGroups("NTU");
for(Group g : groupResults) {
String gName = g.getName();
if(gName.contains("Computer Science")) {
System.out.println(g.getId());
System.out.println(g.getName());
System.out.println();
}
}
} catch (FacebookException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
开发者ID:almightyGOSU,项目名称:CZ4045-NLP-Crawler,代码行数:62,代码来源:OLD_Facebook4JTester.java
示例7: connectAccount
import facebook4j.conf.ConfigurationBuilder; //导入依赖的package包/类
public void connectAccount() throws FacebookException {
connect();
facebook4j.Facebook facebook = getConnection();
User user = facebook.getMe();
if (this.userName == null || !this.userName.equals(user.getId())) {
this.userName = user.getId();
this.profileName = user.getName();
}
this.pageId = "";
if (this.page != null && !this.page.isEmpty()) {
if (facebook.getPage() == null || !facebook.getPage().getName().equals(this.page)) {
// Reset page access token.
boolean found = false;
ResponseList<Account> accounts = this.connection.getAccounts();
if (accounts != null) {
for (Account account : accounts) {
if (this.page.equals(account.getName())) {
found = true;
this.token = account.getAccessToken();
this.userName = account.getId();
this.profileName = account.getName();
String key = getOauthKey();
String secret = getOauthSecret();
if (this.appOauthKey != null && !this.appOauthKey.isEmpty()) {
key = this.appOauthKey;
}
if (this.appOauthSecret != null && !this.appOauthSecret.isEmpty()) {
secret = this.appOauthSecret;
}
ConfigurationBuilder config = new ConfigurationBuilder();
config.setOAuthAppId(key);
config.setOAuthAppSecret(secret);
config.setOAuthAccessToken(getToken());
facebook = new FacebookFactory(config.build()).getInstance();
setConnection(facebook);
this.pageId = facebook.getPage().getId();
log("Connected to Facebook page", Level.INFO, facebook.getPage().getId(), facebook.getPage().getName());
}
}
}
if (!found) {
throw new BotException("Page missing");
}
}
}
saveProperties(null);
}
开发者ID:BotLibre,项目名称:BotLibre,代码行数:49,代码来源:Facebook.java
注:本文中的facebook4j.conf.ConfigurationBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论