• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AccessToken类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中facebook4j.auth.AccessToken的典型用法代码示例。如果您正苦于以下问题:Java AccessToken类的具体用法?Java AccessToken怎么用?Java AccessToken使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AccessToken类属于facebook4j.auth包,在下文中一共展示了AccessToken类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getRawFacebookExchangeToken

import facebook4j.auth.AccessToken; //导入依赖的package包/类
/**
 * 
 * @return
 * @throws FacebookException
 * @throws JSONException 
 */
private AccessToken getRawFacebookExchangeToken() throws FacebookException, JSONException{
    String url = "https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token";
    String appId = configuration.getOAuthAppId(); 
    String secret = configuration.getOAuthAppSecret(); 
    String oldToken = configuration.getOAuthAccessToken(); 

    url += "&client_id="+appId+
           "&client_secret="+secret+
           "&fb_exchange_token="+oldToken;

    logger.info("entro a generar el nuevo token con el URL "+ url);
    JSONObject json = getRawFacebookCall(url);

    return new AccessToken(json.getString("access_token"), json.getLong("expires"));
    
}
 
开发者ID:developersdo,项目名称:developer-influencers,代码行数:23,代码来源:Worker.java


示例2: FacebookFeed

import facebook4j.auth.AccessToken; //导入依赖的package包/类
public FacebookFeed(String searchTerm) {
    //this.setConsumer("Put Consumer Key Here", "Put Consumer Secret Here");
    //this.setToken("Put Token Here");

    this.fbInstance = FacebookFactory.getSingleton();

    fbInstance.setOAuthAppId(this.getConsumerKey(), this.getConsumerSecret());
    fbInstance.setOAuthAccessToken(new AccessToken(this.getToken()));

    try {
        messages = fbInstance.searchPosts(searchTerm);
        System.out.println(messages.size() + " messages retrieved.");
    } catch (FacebookException ex) {
        Logger.getLogger(FacebookFeed.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:ewidgetfx,项目名称:ewidgetfx,代码行数:17,代码来源:FacebookFeed.java


示例3: getPages

import facebook4j.auth.AccessToken; //导入依赖的package包/类
/**
 * Returns a list of all Facebook pages managed by the current user.
 *
 * @param req the http request
 * @return list of all Facebook pages managed by the current user
 * @throws IOException if an error occurred during access
 */
public static ResponseList<Account> getPages(HttpServletRequest req) throws IOException {
    if (AuthHelper.isAuthenticated(req)) {
        initFacebook(req);

        try {
            AccessToken at = Tokenmanager.getFacebookAccessToken(req);
            facebook.setOAuthAccessToken(at);
            return facebook.getAccounts();
        } catch (FacebookException | IllegalStateException e) {
            return null;
        }
    }
    return null;
}
 
开发者ID:slauber,项目名称:Crawcial,代码行数:22,代码来源:FbServlet.java


示例4: main

import facebook4j.auth.AccessToken; //导入依赖的package包/类
public static void main(String atgs[]) throws IOException, JSONException {
	Facebook facebook = new FacebookFactory().getInstance();
	
	facebook.setOAuthAppId(appId,appSecret);
	facebook.setOAuthPermissions(permissions);
	facebook.setOAuthAccessToken(new AccessToken(accessToken,1463769000L));
	String keyword = "spallions";
	Long fromTimestamp = 1463855400L; //22 may
	Long toTimestamp = ((new Date()).getTime())/1000;
	
}
 
开发者ID:qcri-social,项目名称:AIDR,代码行数:12,代码来源:FbCollectorTest.java


示例5: authorizeComplete

import facebook4j.auth.AccessToken; //导入依赖的package包/类
/**
 * Authorise a new account to be accessible by Bot.
 */
public void authorizeComplete(String pin) throws FacebookException {
	AccessToken token = this.connection.getOAuthAccessToken(pin);
    setToken(token.getToken());

	User user = this.connection.getMe();
	this.userName = user.getId();
	if (token.getExpires() != null) {
		this.tokenExpiry = new Date(System.currentTimeMillis() + (token.getExpires() * 1000));
	}
	this.profileName = user.getName();

	try {
		this.page = "";
		ResponseList<Account> accounts = this.connection.getAccounts();
		this.pages = new ArrayList<String>();
		if (accounts != null) {
			for (Account account : accounts) {
				this.page = account.getName();
				this.pages.add(account.getName());
			}
		}
	} catch (Exception exception) {
		log(exception);
	}
    
   /* Map<String, String> params = new HashMap<String, String>();
    params.put("client_id", this.oauthKey);
    params.put("client_secret", this.oauthSecret);
    params.put("grant_type", "fb_exchange_token");
    params.put("fb_exchange_token", token.getToken());

    RawAPIResponse apiResponse = this.connection.callGetAPI("/oauth/access_token", params);

    String response = apiResponse.asString();
    AccessToken newAccessToken = new AccessToken(response);

    this.connection.setOAuthAccessToken(newAccessToken);
    setToken(newAccessToken.getToken());

	this.tokenExpiry = new Date(System.currentTimeMillis() + (newAccessToken.getExpires() * 1000));
	System.out.println(this.tokenExpiry);*/
}
 
开发者ID:BotLibre,项目名称:BotLibre,代码行数:46,代码来源:Facebook.java


示例6: getRawFacebookExchangeToken

import facebook4j.auth.AccessToken; //导入依赖的package包/类
/**
 * 
 * @return
 * @throws FacebookException
 * @throws JSONException 
 */
private AccessToken getRawFacebookExchangeToken() throws FacebookException, JSONException{
    
    String appId = configuration.getOAuthAppId();
    String secret = configuration.getOAuthAppSecret();
    String oldToken = configuration.getOAuthAccessToken();
    
    String url = "https://graph.facebook.com/oauth/access_token?client_id="+appId+"&client_secret="+secret+"&grant_type=fb_exchange_token&fb_exchange_token="+oldToken;

    logger.info("entro a generar el nuevo token con el URL "+ url);
    JSONObject json = getRawFacebookCall(url);

    return new AccessToken(json.getString("access_token"), json.getLong("expires"));
    
}
 
开发者ID:developersdo,项目名称:developer-influencers,代码行数:21,代码来源:SignIn.java


示例7: setFbVars

import facebook4j.auth.AccessToken; //导入依赖的package包/类
/**
 * This method sets the facebook4j client and the user access token.
 *
 * @param fb    preconfigured facebook4j client
 * @param token Facebook user access token
 */
public static void setFbVars(Facebook fb, AccessToken token) {
    FacebookStreamer.fb = fb;
    FacebookStreamer.token = token;
}
 
开发者ID:slauber,项目名称:Crawcial,代码行数:11,代码来源:FacebookStreamer.java


示例8: setFbVars

import facebook4j.auth.AccessToken; //导入依赖的package包/类
/**
 * This method sets the facebook4j client and the user access token.
 *
 * @param fb    preconfigured facebook4j client
 * @param token Facebook user access token
 */
public void setFbVars(Facebook fb, AccessToken token) {
    FacebookStaticLoader.fb = fb;
    FacebookStaticLoader.token = token;
}
 
开发者ID:slauber,项目名称:Crawcial,代码行数:11,代码来源:FacebookStaticLoader.java



注:本文中的facebook4j.auth.AccessToken类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Billing类代码示例发布时间:2022-05-22
下一篇:
Java InteractiveConsole类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap