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

Java FacebookOAuthException类代码示例

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

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



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

示例1: oauthExceptionWithErrorSubcode

import com.restfb.exception.FacebookOAuthException; //导入依赖的package包/类
/**
 * Do we correctly handle the case where FB returns an OAuthException with an error code and subcode?
 */
@Test
public void oauthExceptionWithErrorSubcode() {
  FacebookClient facebookClient =
      facebookClientWithResponse(new Response(403,
        "{\"error\":{\"message\":\"App Not Installed\",\"type\":\"OAuthException\",\"code\":190,\"error_subcode\":458}}"));

  try {
    facebookClient.fetchObject("me", User.class);
  } catch (FacebookOAuthException e) {
    assertEquals("App Not Installed", e.getErrorMessage());
    assertEquals("OAuthException", e.getErrorType());
    assertEquals(Integer.valueOf(190), e.getErrorCode());
    assertEquals(Integer.valueOf(458), e.getErrorSubcode());
  }
}
 
开发者ID:oleke,项目名称:Gender-Mining,代码行数:19,代码来源:FacebookClientTest.java


示例2: fetchObject

import com.restfb.exception.FacebookOAuthException; //导入依赖的package包/类
public static <T> T fetchObject(FacebookClient fbClient, String name, Class<T> objClass,
    Parameter... parameters) {
  try {
    return fbClient.fetchObject(name, objClass, parameters);
  } catch(FacebookException e) {
    if (e instanceof FacebookOAuthException) {
      throw ErrorResponseMsg.createException(e.getMessage(), ErrorInfo.Type.AUTHENTICATION);
    }
    if (e.getMessage().toLowerCase().contains("unsupported get request")) {
      // This seems to be thrown when there is a permissions issue.
      // http://stackoverflow.com/questions/6843796/graph-api-returns-false-or-unsupported-get-request-accessing-public-facebook
      throw ErrorResponseMsg.createException(
        "Access to faceboook object '" + name + "' is restricted",
        ErrorInfo.Type.PARTNER_SERVICE_FAILURE);
    }
    throw ErrorResponseMsg.createException(e, ErrorInfo.Type.PARTNER_SERVICE_FAILURE);
  }
}
 
开发者ID:karma-exchange-org,项目名称:karma-exchange,代码行数:19,代码来源:FacebookSocialNetworkProvider.java


示例3: setUp

import com.restfb.exception.FacebookOAuthException; //导入依赖的package包/类
@Before
public void setUp() {
    this.callbackHandler = mock(CallbackHandler.class);
    this.facebookClient = mock(FacebookClient.class);
    this.facebookOAuthException = mock(FacebookOAuthException.class);
    this.jsonMapper = mock(JsonMapper.class);
    this.messenger = new DefaultMessenger(verifyToken, appSecret, callbackHandler, facebookClient);
    when(facebookClient.getJsonMapper()).thenReturn(jsonMapper);
}
 
开发者ID:marsbits,项目名称:restfbmessenger,代码行数:10,代码来源:DefaultMessengerTests.java


示例4: oauthExceptionWithErrorCode

import com.restfb.exception.FacebookOAuthException; //导入依赖的package包/类
/**
 * Do we correctly handle the case where FB returns an OAuthException with an error code?
 */
@Test
public void oauthExceptionWithErrorCode() {
  FacebookClient facebookClient =
      facebookClientWithResponse(new Response(403,
        "{\"error\":{\"message\":\"(#210) User not visible\",\"type\":\"OAuthException\",\"code\":210}}"));

  try {
    facebookClient.fetchObject("me", User.class);
  } catch (FacebookOAuthException e) {
    assertEquals("(#210) User not visible", e.getErrorMessage());
    assertEquals("OAuthException", e.getErrorType());
    assertEquals(Integer.valueOf(210), e.getErrorCode());
  }
}
 
开发者ID:oleke,项目名称:Gender-Mining,代码行数:18,代码来源:FacebookClientTest.java


示例5: oauthExceptionWithoutErrorCode

import com.restfb.exception.FacebookOAuthException; //导入依赖的package包/类
/**
 * Do we correctly handle the case where FB returns an OAuthException without an error code?
 */
@Test
public void oauthExceptionWithoutErrorCode() {
  FacebookClient facebookClient =
      facebookClientWithResponse(new Response(403,
        "{\"error\":{\"message\":\"(#210) User not visible\",\"type\":\"OAuthException\"}}"));

  try {
    facebookClient.fetchObject("me", User.class);
  } catch (FacebookOAuthException e) {
    assertEquals("(#210) User not visible", e.getErrorMessage());
    assertEquals("OAuthException", e.getErrorType());
    assertEquals(null, e.getErrorCode());
  }
}
 
开发者ID:oleke,项目名称:Gender-Mining,代码行数:18,代码来源:FacebookClientTest.java


示例6: exceptionForTypeAndMessage

import com.restfb.exception.FacebookOAuthException; //导入依赖的package包/类
/**
 * @see com.restfb.exception.FacebookExceptionMapper#exceptionForTypeAndMessage(java.lang.Integer,
 *      java.lang.Integer, java.lang.String, java.lang.String)
 */
public FacebookException exceptionForTypeAndMessage(Integer errorCode, Integer errorSubcode,
    Integer httpStatusCode, String type, String message) {
  if ("OAuthException".equals(type) || "OAuthAccessTokenException".equals(type))
    return new FacebookOAuthException(type, message, errorCode, errorSubcode, httpStatusCode);

  if ("QueryParseException".equals(type))
    return new FacebookQueryParseException(type, message, errorCode, errorSubcode, httpStatusCode);

  // Don't recognize this exception type? Just go with the standard
  // FacebookGraphException.
  return new FacebookGraphException(type, message, errorCode, errorSubcode, httpStatusCode);
}
 
开发者ID:oleke,项目名称:Gender-Mining,代码行数:17,代码来源:DefaultFacebookClient.java


示例7: exceptionForTypeAndMessage

import com.restfb.exception.FacebookOAuthException; //导入依赖的package包/类
/**
 * @see com.restfb.exception.FacebookExceptionMapper#exceptionForTypeAndMessage(java.lang.Integer,
 *      java.lang.Integer, java.lang.String, java.lang.String)
 */
@Override
public FacebookException exceptionForTypeAndMessage(Integer errorCode, Integer errorSubcode,
    Integer httpStatusCode, String type, String message) {
  if (errorCode == API_EC_PARAM_ACCESS_TOKEN)
    return new FacebookOAuthException(String.valueOf(errorCode), message, errorCode, errorSubcode, httpStatusCode);

  // Don't recognize this exception type? Just go with the standard
  // FacebookResponseStatusException.
  return new FacebookResponseStatusException(errorCode, message);
}
 
开发者ID:oleke,项目名称:Gender-Mining,代码行数:15,代码来源:BaseFacebookClient.java


示例8: isValidated

import com.restfb.exception.FacebookOAuthException; //导入依赖的package包/类
public static boolean isValidated(String accessToken, String userID) {
	try {
		FacebookClient fc = new DefaultFacebookClient(accessToken, Version.VERSION_2_4);
		String id = fc.fetchObject("me", User.class).getId();
		if (!id.equals(userID)) {
			return false;
		}
		return true;
	} catch (FacebookOAuthException e) {
		e.printStackTrace();
		return false;
	}
}
 
开发者ID:JaewookByun,项目名称:epcis,代码行数:14,代码来源:OAuthUtil.java


示例9: isValidatedFacebookClient

import com.restfb.exception.FacebookOAuthException; //导入依赖的package包/类
public static FacebookClient isValidatedFacebookClient(String accessToken, String userID) {
	try {
		FacebookClient fc = new DefaultFacebookClient(accessToken, Version.VERSION_2_4);
		String id = fc.fetchObject("me", User.class).getId();
		if (!id.equals(userID)) {
			return null;
		}
		return fc;
	} catch (FacebookOAuthException e) {
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:JaewookByun,项目名称:epcis,代码行数:14,代码来源:OAuthUtil.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java Cleanable类代码示例发布时间:2022-05-22
下一篇:
Java LoadBinaryResponseHandler类代码示例发布时间: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