本文整理汇总了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;未经允许,请勿转载。 |
请发表评论