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


Java FacebookApi类代码示例

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


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

示例1: getUserInfoJSON

import org.scribe.builder.api.FacebookApi; //导入依赖的package包/类
private JSONObject getUserInfoJSON(String code, String callBackUrl) {
    OAuthService service = new ServiceBuilder()
            .provider(FacebookApi.class)
            .apiKey(apiKey)
            .apiSecret(apiSecret)
            .callback(host + callBackUrl)
            .scope("email")
            .build();
    Verifier verifier = new Verifier(code);
    Token accessToken = service.getAccessToken(NULL_TOKEN, verifier);
    OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL);
    request.addOAuthParameter("scope", "email");
    service.signRequest(accessToken, request);
    Response response = request.send();
    LOG.info("response body is " + response.getBody());
    try {
        JSONObject obj = new JSONObject(response.getBody());
        obj.put("access_token", accessToken.getToken());
        return obj;
    } catch (JSONException e) {
        return new JSONObject();
    }
}
 
开发者ID:cilogi,项目名称:lid,代码行数:24,代码来源:FacebookLoginServlet.java

示例2: FacebookOAuthService

import org.scribe.builder.api.FacebookApi; //导入依赖的package包/类
@Inject
FacebookOAuthService(
    PluginConfigFactory cfgFactory,
    @PluginName String pluginName,
    @CanonicalWebUrl Provider<String> urlProvider) {

  PluginConfig cfg = cfgFactory.getFromGerritConfig(pluginName + CONFIG_SUFFIX);
  String canonicalWebUrl = CharMatcher.is('/').trimTrailingFrom(urlProvider.get()) + "/";

  service =
      new ServiceBuilder()
          .provider(FacebookApi.class)
          .apiKey(cfg.getString(InitOAuth.CLIENT_ID))
          .apiSecret(cfg.getString(InitOAuth.CLIENT_SECRET))
          .callback(canonicalWebUrl + "oauth")
          .scope(SCOPE)
          .build();
}
 
开发者ID:davido,项目名称:gerrit-oauth-provider,代码行数:19,代码来源:FacebookOAuthService.java

示例3: login

import org.scribe.builder.api.FacebookApi; //导入依赖的package包/类
/**
 * Log in.
 *
 * @param key Facebook key
 * @param secret Facebook secret
 * @param tokenPath Path to save the token
 * @param vCode How to get the verification code
 * @throws IOException
 * @throws InterruptedException
 * @throws com.vaushell.superpipes.tools.scribe.fb.FacebookException
 */
public void login( final String key ,
                   final String secret ,
                   final Path tokenPath ,
                   final A_ValidatorCode vCode )
    throws IOException , InterruptedException , FacebookException
{
    loginImpl( FacebookApi.class ,
               key ,
               secret ,
               "read_stream,publish_actions" ,
               "http://www.facebook.com/connect/login_success.html" ,
               false ,
               tokenPath ,
               vCode );

    target = getMeID();
    page = false;
}
 
开发者ID:fabienvauchelles,项目名称:superpipes,代码行数:30,代码来源:FacebookClient.java

示例4: loginAsPage

import org.scribe.builder.api.FacebookApi; //导入依赖的package包/类
/**
 * Log in as a page.
 *
 * @param pageName Page name (not the ID)
 * @param key Facebook key
 * @param secret Facebook secret
 * @param tokenPath Path to save the token
 * @param vCode How to get the verification code
 * @throws IOException
 * @throws InterruptedException
 * @throws FacebookException
 */
public void loginAsPage( final String pageName ,
                         final String key ,
                         final String secret ,
                         final Path tokenPath ,
                         final A_ValidatorCode vCode )
    throws IOException , InterruptedException , FacebookException
{
    loginImpl( FacebookApi.class ,
               key ,
               secret ,
               "read_stream,publish_actions,manage_pages" ,
               "http://www.facebook.com/connect/login_success.html" ,
               false ,
               tokenPath ,
               vCode );

    target = getPageIDandChangeToken( pageName );
    page = true;
}
 
开发者ID:fabienvauchelles,项目名称:superpipes,代码行数:32,代码来源:FacebookClient.java

示例5: loginURL

import org.scribe.builder.api.FacebookApi; //导入依赖的package包/类
private String loginURL(@NonNull String redirectURL) {
    Preconditions.checkArgument(redirectURL.startsWith("/"));

    OAuthService service = new ServiceBuilder()
            .provider(FacebookApi.class)
            .apiKey(apiKey)
            .apiSecret(apiSecret)
            .callback(host + redirectURL)
            .scope("email")
            .build();
    return service.getAuthorizationUrl(null);
}
 
开发者ID:cilogi,项目名称:lid,代码行数:13,代码来源:FacebookLoginServlet.java

示例6: getInstanceFacebook

import org.scribe.builder.api.FacebookApi; //导入依赖的package包/类
@Produces
@Facebook
public OAuthService getInstanceFacebook() {
	this.service = new ServiceBuilder()
	.provider(FacebookApi.class)
	.apiKey(env.get(FACEBOOK_CLIENT_ID))
	.apiSecret(env.get(FACEBOOK_APP_SECRET))
			.callback(env.get("host")+env.get(FACEBOOK_REDIRECT_URI))
	.build();
	return service;
}
 
开发者ID:caelum,项目名称:mamute,代码行数:12,代码来源:OAuthServiceCreator.java

示例7: doAuth

import org.scribe.builder.api.FacebookApi; //导入依赖的package包/类
@Override
protected void doAuth( Intent intent )
{
    final String code = intent.getStringExtra( SitesLoginHandler.VERIFIER_KEY );
    Token accessToken = null;
    String userName = null;
    try
    {
        OAuthService service = new ServiceBuilder()
                .callback( FacebookLoginActivity.FACEBOOK_CALLBACK_URL )
                .provider( FacebookApi.class )
                .apiKey( FacebookConfig.FACEBOOK_OAUTH_APP_ID )
                .apiSecret( FacebookConfig.FACEBOOK_OAUTH_APP_SECRET )
                .build();
        accessToken = service.getAccessToken( null, new Verifier( code ) );
        OAuthRequest request = new OAuthRequest( Verb.GET, FACEBOOK_USERNAME_URL );
        service.signRequest( accessToken, request );
        Response response = request.send();
        userName = Helper.extractJsonStringField( response.getBody(), "name" );
    }
    catch ( Exception e )
    {
        Helper.debug( "Failed to get Facebook access token : " + e.getMessage() );
    }
    boolean success = null != accessToken;
    // Subscriber : FacebookLoginHandler : onFacebookAuthDone()
    HashtaggerApp.bus.post( new FacebookAuthDoneEvent( success, accessToken, userName ) );
}
 
开发者ID:iTwenty,项目名称:Hashtagger,代码行数:29,代码来源:FacebookService.java

示例8: getProviderClass

import org.scribe.builder.api.FacebookApi; //导入依赖的package包/类
@Override
protected Class<? extends Api> getProviderClass()
{
    return FacebookApi.class;
}
 
开发者ID:iTwenty,项目名称:Hashtagger,代码行数:6,代码来源:FacebookSigningClient.java

示例9: main

import org.scribe.builder.api.FacebookApi; //导入依赖的package包/类
public static void main(String[] args) {

        if (args.length < 1) {
            System.err.println("You need to pass the Facebook API secret as a first parameter on the command-line!");
            System.exit(-1);
        }
        String apiSecret = args[0];

		OAuthService service = new ServiceBuilder()
			.provider(FacebookApi.class)
			.apiKey(apiKey)
			.apiSecret(apiSecret)
			.callback("http://www.facebook.com/connect/login_success.html")
		.build();

		Scanner in = new Scanner(System.in);

		System.out.println("=== " + NETWORK_NAME + "'s OAuth Workflow ===");
		System.out.println();

		// Obtain the Authorization URL
		System.out.println("Fetching the Authorization URL...");
		String authorizationUrl = service.getAuthorizationUrl(EMPTY_TOKEN);
		System.out.println("Got the Authorization URL!");
		System.out.println("Now go and authorize Scribe here:");
		System.out.println(authorizationUrl);
		System.out.println("And paste the authorization code here");
		System.out.print(">>");
		Verifier verifier = new Verifier(in.nextLine());
		System.out.println();

		// Trade the Request Token and Verfier for the Access Token
		System.out.println("Trading the Request Token for an Access Token...");
		Token accessToken = service.getAccessToken(EMPTY_TOKEN, verifier);
		System.out.println("Got the Access Token!");
		System.out.println("(if your curious it looks like this: " + accessToken + " )");
		System.out.println();

		// Now let's go and ask for a protected resource!
		System.out.println("Now we're going to access a protected resource...");
		OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL);
		service.signRequest(accessToken, request);
		Response response = request.send();
		System.out.println("Got it! Lets see what we found...");
		System.out.println();
		System.out.println(response.getCode());
		System.out.println(response.getBody());

		System.out.println();
		System.out.println("Thats it man! Go and build something awesome with Scribe! :)");

	}
 
开发者ID:plexiti,项目名称:the-job-announcement,代码行数:53,代码来源:Facebook.java

示例10: FacebookButton

import org.scribe.builder.api.FacebookApi; //导入依赖的package包/类
public FacebookButton(String key, String secret) {
	super(FacebookApi.class, key, secret);
	
	setIcon(new ClassResource("/org/vaadin/addon/oauthpopup/icons/facebook16.png"));
	setCaption("Facebook");
}
 
开发者ID:ahn,项目名称:vaadin-oauthpopup,代码行数:7,代码来源:FacebookButton.java

示例11: getApi

import org.scribe.builder.api.FacebookApi; //导入依赖的package包/类
@Override
protected Class<? extends Api> getApi() {
    return FacebookApi.class;
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:5,代码来源:FacebookButton.java

示例12: FacebookHandler

import org.scribe.builder.api.FacebookApi; //导入依赖的package包/类
public FacebookHandler() {
    service = new ServiceBuilder().provider(FacebookApi.class)
            .apiKey(APP_ID).apiSecret(APP_SECRET)
            .callback("http://test.anycook.de/anycook/NewFacebookUser").build();
}
 
开发者ID:anycook,项目名称:anycook-api,代码行数:6,代码来源:FacebookHandler.java


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