当前位置: 首页>>代码示例>>Java>>正文


Java DefaultFacebookClient类代码示例

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


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

示例1: fetchFacebookUser

import com.restfb.DefaultFacebookClient; //导入依赖的package包/类
private AuthUser fetchFacebookUser(String accessToken)
{
    //TODO: this takes too long, maybe cache the access token for a configurable time
    FacebookClient client = new DefaultFacebookClient(accessToken, Version.VERSION_2_5);
    try
    {
        User user = client.fetchObject("me", User.class, Parameter.with("fields", "name,email"));
        if (user != null)
        {
            AuthUser authUser = new AuthUser();
            authUser.setName(user.getName());
            authUser.setEmail(user.getEmail());
            authUser.setAuthVendor(AuthVendor.FACEBOOK);
            authUser.setSession(accessToken);

            return authUser;
        }
    }
    catch (FacebookException ex)
    {
    }

    return null;
}
 
开发者ID:touwolf,项目名称:kasije,代码行数:25,代码来源:FacebookAuthProvider.java

示例2: SearchForTermUsingGeolocation

import com.restfb.DefaultFacebookClient; //导入依赖的package包/类
public void SearchForTermUsingGeolocation(String queryPar, int PageSize,
		double latitude, double longitude, double radius) {
	if (queryPar != null) {
		facebookClient = new DefaultFacebookClient();
		publicSearch = facebookClient.fetchConnection("search", Post.class,
				Parameter.with("q", queryPar),
				Parameter.with("type", "post"),
				Parameter.with("limit", PageSize),
				Parameter.with("place&center", latitude + "," + longitude),
				Parameter.with("distance", radius));

		for (int i = 0; i < publicSearch.getData().size(); i++) {
			if (publicSearch.getData().get(i).getMessage() != null) {
				results.add(new FacebookPostData(publicSearch.getData()
						.get(i)));
				OldestDate = publicSearch.getData().get(i).getCreatedTime();
			}
		}

	}
}
 
开发者ID:SmartSearch,项目名称:Edge-Node,代码行数:22,代码来源:FacebookDriver.java

示例3: collectFeed

import com.restfb.DefaultFacebookClient; //导入依赖的package包/类
private Connection<Post> collectFeed(String pagename) {
	
	AccessToken accessToken = new DefaultFacebookClient(Version.VERSION_2_3).obtainAppAccessToken(ConfigurationObject.MY_APP_ID, ConfigurationObject.MY_APP_SECRET);
	FacebookClient facebookClient23 = new DefaultFacebookClient(accessToken.getAccessToken(), Version.VERSION_2_3);

	//User user = facebookClient23.fetchObject("me", User.class);
	Page page = facebookClient23.fetchObject(pagename, Page.class, Parameter.with("fields","name,id, picture, likes"));
	return  facebookClient23.fetchConnection(page.getId()+"/feed", Post.class, Parameter.with("fields", "comments, full_picture")); //message,picture, likes, from,
}
 
开发者ID:chenav,项目名称:orufeo,代码行数:10,代码来源:FacebookBoImpl.java

示例4: testDefaultAutoConfiguration

import com.restfb.DefaultFacebookClient; //导入依赖的package包/类
@Test
public void testDefaultAutoConfiguration() {
    load(new Class[] {CallbackHandlerConfig.class, MessengerAutoConfiguration.class},
            "restfbmessenger.verify-token: the_verify_token",
            "restfbmessenger.access-token: the_access_token",
            "restfbmessenger.app-secret: the_app_secret");

    Messenger messenger = this.context.getBean(Messenger.class);
    DefaultMessenger defaultMessenger = (DefaultMessenger) messenger;
    FacebookClient facebookClient =
            (FacebookClient) getFieldValue(defaultMessenger, "facebookClient");
    DefaultFacebookClient defaultFacebookClient = (DefaultFacebookClient) facebookClient;
    CallbackHandler callbackHandler =
            (CallbackHandler) getFieldValue(defaultMessenger, "callbackHandler");

    assertThat((String) getFieldValue(defaultMessenger, "verifyToken"), is("the_verify_token"));
    assertThat((String) getFieldValue(defaultMessenger, "appSecret"), is("the_app_secret"));
    assertThat((String) getFieldValue(defaultFacebookClient, "accessToken"),
            is("the_access_token"));
    assertThat((String) getFieldValue(defaultFacebookClient, "appSecret"),
            is("the_app_secret"));
    assertThat(callbackHandler, is(notNullValue()));
    assertThat(this.context.getBean(ServletRegistrationBean.class).getUrlMappings(),
            hasItem("/webhook/*"));
}
 
开发者ID:marsbits,项目名称:restfbmessenger,代码行数:26,代码来源:MessengerAutoConfigurationTests.java

示例5: testSerializer

import com.restfb.DefaultFacebookClient; //导入依赖的package包/类
@Before
public void testSerializer()
{
	if (circles == 0)
	{
		if (!ConfLoader.confExists())
			ConfLoader.genProperties();
		String CURRENT_ACCESSTOKEN = ConfLoader.getProperties().getProperty(PropertyOption.ACCESS_TOKEN.toString());
		maxPics = (long) -1;
		try
		{
			maxPics = Long.parseLong(ConfLoader.getProperties().getProperty(PropertyOption.MAX_PHOTOS_PER_ALBUM.toString()));
		} catch (NumberFormatException e)
		{

		}
		skipAlbums = new ArrayList<>();
		skipAlbums.addAll(Arrays.asList(ConfLoader.getProperties().getProperty(PropertyOption.SKIP_ALBUMS.toString()).split(";")));
		fbc = new DefaultFacebookClient(CURRENT_ACCESSTOKEN, Version.VERSION_2_3);
		facebook = new Facebook(fbc);
		dir = new File(ConfLoader.getProperties().getProperty(PropertyOption.DIRECTORY.toString()));
	}
	circles++;
}
 
开发者ID:RStoeckl,项目名称:themis-fb,代码行数:25,代码来源:DownloadTester.java

示例6: setNextPage

import com.restfb.DefaultFacebookClient; //导入依赖的package包/类
public void setNextPage() {

		results = new ArrayList();
		/*
		 * publicSearch = facebookClient.fetchConnectionPage(
		 * publicSearch.getNextPageUrl(), Post.class);
		 */
		facebookClient = new DefaultFacebookClient();
		publicSearch = facebookClient.fetchConnectionPage(
				publicSearch.getNextPageUrl(), Post.class);

		for (int i = 0; i < publicSearch.getData().size(); i++) {
			if (publicSearch.getData().get(i).getMessage() != null) {
				results.add(new FacebookPostData(publicSearch.getData().get(i)));
			}
		}
	}
 
开发者ID:SmartSearch,项目名称:Edge-Node,代码行数:18,代码来源:FacebookDriver.java

示例7: setPreviousPage

import com.restfb.DefaultFacebookClient; //导入依赖的package包/类
public void setPreviousPage() {

		results = new ArrayList();
		/*
		 * publicSearch = facebookClient.fetchConnectionPage(
		 * publicSearch.getNextPageUrl(), Post.class);
		 */
		facebookClient = new DefaultFacebookClient();
		publicSearch = facebookClient.fetchConnectionPage(
				publicSearch.getPreviousPageUrl(), Post.class);

		for (int i = 0; i < publicSearch.getData().size(); i++) {
			if (publicSearch.getData().get(i).getMessage() != null) {
				results.add(new FacebookPostData(publicSearch.getData().get(i)));
			}
		}
	}
 
开发者ID:SmartSearch,项目名称:Edge-Node,代码行数:18,代码来源:FacebookDriver.java

示例8: SearchForTerm

import com.restfb.DefaultFacebookClient; //导入依赖的package包/类
@Override
public void SearchForTerm(String queryPar, Integer PageSize) {
	if (queryPar != null) {
		results = new ArrayList();
		facebookClient = new DefaultFacebookClient();
		publicSearch = facebookClient.fetchConnection("search", Post.class,
				Parameter.with("q", queryPar),
				Parameter.with("type", "post"),
				Parameter.with("limit", PageSize));

		for (int i = 0; i < publicSearch.getData().size(); i++) {
			if (publicSearch.getData().get(i).getMessage() != null) {
				results.add(new FacebookPostData(publicSearch.getData()
						.get(i)));
			}
		}

	}

}
 
开发者ID:SmartSearch,项目名称:Edge-Node,代码行数:21,代码来源:FacebookDriver.java

示例9: SearchFacebookPages

import com.restfb.DefaultFacebookClient; //导入依赖的package包/类
public void SearchFacebookPages(String queryPar, Integer PageSize) {
	Connection<Page> publicSearch;
	if (queryPar != null) {
		resultPages = new ArrayList();
		facebookClient = new DefaultFacebookClient();
		publicSearch = facebookClient.fetchConnection("search", Page.class,
				Parameter.with("q", queryPar),
				Parameter.with("type", "page"),
				Parameter.with("limit", PageSize));

		for (int i = 0; i < publicSearch.getData().size(); i++) {
			if (publicSearch.getData().get(i).getName() != null) {
				resultPages.add(new FacebookPageData(publicSearch.getData()
						.get(i)));
			}
		}

	}

}
 
开发者ID:SmartSearch,项目名称:Edge-Node,代码行数:21,代码来源:FacebookDriver.java

示例10: getUserFromFacebookUid

import com.restfb.DefaultFacebookClient; //导入依赖的package包/类
private LoginResult getUserFromFacebookUid(String token) {
	LoginResult loginResult = null;
	
	FacebookClient client = new DefaultFacebookClient(token);
	com.restfb.types.User user = client.fetchObject("me", com.restfb.types.User.class);
	String uid = user.getId();
	try {
		loginResult = db.getLoginInformationUsingNetworkId(FACEBOOK_NAME, uid);
	} catch (SQLException e) {
		logger.Error(e);
		return null;
	}
	String sid = SessionManager.get().createSession(loginResult);
	loginResult.setSid(sid);
	
	if(loginResult.isSuccess() && (loginResult.isAdmin() || !loginResult.isDeleted())) {
		logger.Info("Login user #" + loginResult.getUid() + ": " + loginResult.getUsername() + " (Using Facebook ID #" +uid + " in Web-Application)");
	}
	
	return loginResult;
}
 
开发者ID:jkonert,项目名称:socom,代码行数:22,代码来源:SocialNetworkServiceImpl.java

示例11: getExtendedAccessToken

import com.restfb.DefaultFacebookClient; //导入依赖的package包/类
/**
 * Exchange the short lived token (2h) for a long lived one (60j).
 * 
 * @param accessToken Short lived token
 * @return Long lived token
 * @throws AuthenticationException Invalid token
 */
public String getExtendedAccessToken(String accessToken) throws AuthenticationException {
    FacebookClient facebookClient = new DefaultFacebookClient(accessToken);
    AccessToken extendedAccessToken = null;
    try {
        extendedAccessToken = facebookClient.obtainExtendedAccessToken(facebookAppId, facebookAppSecret, accessToken);

        if (log.isDebugEnabled()) {
            log.debug(MessageFormat.format("Got long lived session token {0} for token {1}", extendedAccessToken, accessToken));
        }
    } catch (FacebookException e) {
        if (e.getMessage().contains("Error validating access token")) {
            throw new AuthenticationException("Error validating access token");
        }
            
        throw new RuntimeException("Error exchanging short lived token for long lived token", e);
    }
    return extendedAccessToken.getAccessToken();
}
 
开发者ID:sismics,项目名称:books,代码行数:26,代码来源:FacebookService.java

示例12: post

import com.restfb.DefaultFacebookClient; //导入依赖的package包/类
@Override
public String post(FacebookPosting posting) {
	try {
		FacebookClient facebookClient = new DefaultFacebookClient(ACCESS_TOKEN);
		FacebookType publishMessageResponse = facebookClient.publish(FACEBOOK_PAGE + "/links", FacebookType.class, 
			Parameter.with("message", posting.getMessage()),
			Parameter.with("link", posting.getLink()),
			Parameter.with("og:name", posting.getName()),
			Parameter.with("description", posting.getDescription()),
			Parameter.with("icon", posting.getPicture()),
			Parameter.with("picture", posting.getPicture())
		);
		String facebookUrl = "http://www.facebook.com/permalink.php?story_fbid=" + publishMessageResponse.getId() + "&id=" + FACEBOOK_PAGE;
		log.info("Successfully posted [" + posting.getMessage() + "] to Facebook at [" + facebookUrl + "].");
		return facebookUrl;
	} catch (RuntimeException e) {
	    log.warning("Failed to post [" + posting.getMessage()  + "] to Facebook.");
		log.throwing(getClass().getName(), "post", e);
		throw e;
	}
}
 
开发者ID:plexiti,项目名称:the-job-announcement,代码行数:22,代码来源:FacebookPostingServiceImpl.java

示例13: run

import com.restfb.DefaultFacebookClient; //导入依赖的package包/类
/**
 * Bezieht die Informationen eines Profils von Facebook
 */
@Override
public void run() {
	apiConnection = new DefaultFacebookClient(this.token);
	auser = apiConnection.fetchObject(user, User.class);
	
	FacebookProfile fbp = new FacebookProfile(auser.getUsername(), auser.getId());
	
    fbp.setName(auser.getFirstName(), auser.getLastName());
    fbp.setLink(auser.getLink());
    fbp.setLocales(auser.getLocale());
    
    queue.add(fbp);
    if (FacePath.DEBUG >= 4){
    	System.out.println("GUFAPI-created: "+user);
    }
}
 
开发者ID:fabiogermann,项目名称:zhaw-facepath,代码行数:20,代码来源:GetUserFromAPIThread.java

示例14: createUser

import com.restfb.DefaultFacebookClient; //导入依赖的package包/类
@Override
public UserInfo createUser(CredentialVerificationResult verificationResult) {
  FacebookCredentialVerificationCtx ctx =
      (FacebookCredentialVerificationCtx) verificationResult.getVerificationCtx();
  DefaultFacebookClient fbClient = new DefaultFacebookClient(ctx.getAuthToken());
  // Getting age_range unfortunately requires explicitly specifiying the fields.
  ExtFbUser fbUser = fetchObject(fbClient, "me", ExtFbUser.class,
    Parameter.with("fields", "id, first_name, last_name, email, location, age_range, gender"));
  User user = User.create();
  user.setFirstName(fbUser.getFirstName());
  user.setLastName(fbUser.getLastName());
  if (fbUser.getEmail() != null) {
    user.getRegisteredEmails().add(new RegisteredEmail(fbUser.getEmail(), true));
  }
  user.setAddress(parseCity(fbUser));
  user.setGender(parseGender(fbUser));
  user.setAgeRange(parseAgeRange(fbUser));
  return new UserInfo(user,
    new UserInfo.ProfileImage(
      ImageProviderType.FACEBOOK,
      getProfileImageUrl(fbUser.getId())) );
}
 
开发者ID:karma-exchange-org,项目名称:karma-exchange,代码行数:23,代码来源:FacebookSocialNetworkProvider.java

示例15: initOrganization

import com.restfb.DefaultFacebookClient; //导入依赖的package包/类
@Override
public void initOrganization(Organization org, String fbPageName) {
  DefaultFacebookClient fbClient = new DefaultFacebookClient(getAppCredentials().getToken());
  // Getting age_range unfortunately requires explicitly specifiying the fields.
  Page fbPage = fetchObject(fbClient, fbPageName, Page.class);

  // Relying on fb page name uniqueness
  org.setName(Organization.orgIdToName(fbPageName));
  org.setOrgName(fbPage.getName());
  org.setPage(PageRef.create(fbPageName, PAGE_BASE_URL + fbPageName,
    SocialNetworkProviderType.FACEBOOK));
  String mission = null;
  if (fbPage.getMission() != null) {
    mission = fbPage.getMission();
  } else if (fbPage.getAbout() != null) {
    mission = fbPage.getAbout();
  }
  org.setMission(mission);
  org.setAddress(getAddress(fbPage.getLocation()));
}
 
开发者ID:karma-exchange-org,项目名称:karma-exchange,代码行数:21,代码来源:FacebookSocialNetworkProvider.java


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