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


Java FacebookException.getMessage方法代码示例

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


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

示例1: isFriendWithCurrentUser

import com.restfb.exception.FacebookException; //导入方法依赖的package包/类
@Override
public boolean isFriendWithCurrentUser(String externalUserId,
        User currentUser) {
    if (!isServiceEnabled(currentUser)) {
        return false;
    }

    FacebookClient client = helper.getFacebookClient(currentUser);
    try {
        com.restfb.types.User friend = client.fetchObject(
                currentUser.getFacebookSettings().getUserId() + "/friends/"
                    + getFacebookId(externalUserId),
                com.restfb.types.User.class);

        return friend != null;
    } catch (FacebookException ex) {
        if (ex.getMessage() != null && ex.getMessage().contains("#110")) {
            //TODO this is a page, handle pages as well
            return true;
        } else {
            handleException("Problem getting friends of user " + externalUserId, ex, currentUser);
        }
    }
    return false;
}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:26,代码来源:FacebookService.java

示例2: handleException

import com.restfb.exception.FacebookException; //导入方法依赖的package包/类
private void handleException(String message, FacebookException ex, User user) {
    SocialNetworkStatusHolder.addStatus("facebookProblem");

    // well, technically, this is not a best practice,
    // but thus a lot of code duplication is avoided.
    // Also, checking for a string in the exception message
    // is not good, but that seems the only way to determine the exact exception
    if (ex instanceof FacebookNetworkException) {
        logger.warn(message + ": " + ex.getMessage() + " : " + ExceptionUtils.getRootCauseMessage(ex));
    } else if (ex instanceof FacebookGraphException) {
        if (ex.getMessage() != null) {
            String errorMessage = ex.getMessage().toLowerCase();
            // if the token is not valid, or the user has revoked a
            // permission (arbitrarily chosen manage_notifications),
            // disconnect
            if (errorMessage.contains("validating access token") || errorMessage.contains("manage_notifications")) {
                // resetting facebook token
                SocialNetworkStatusHolder.addStatus("facebookTokenProblem");
                logger.info("Access token problem with user " + user + ". Resetting token. The problem is due to exception: " + ex.getMessage());
                user.getFacebookSettings().setDisconnectReason(errorMessage);
                helper.forciblyDisconnect(this, user);
                return;
            }

            if (errorMessage.contains("#803") // object missing
                    || errorMessage.contains("#200") // object not accessible
                    || errorMessage.contains("#210") // user not accessible
                    || errorMessage.contains("#100") // invalid parameter - given when delete is attempted on non-existent status
                    || errorMessage.contains("#506") // duplicate status
                    || errorMessage.contains("Unsupported delete request")) { // missing target object for deletion
                // ignore, do nothing, log in debug only
                logger.debug(message + ": " + ex.getMessage() + " : " + ExceptionUtils.getRootCauseMessage(ex), " | User is " + user);
                return;
            }

            if (errorMessage.contains("#341")) {
                logger.info("Facebook post limit reached by user: " + user);
                return;
            }
        }
        logger.warn(message + " | User is " + user, ex);
    } else {
        logger.warn(message + " | User is " + user, ex);
    }
}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:46,代码来源:FacebookService.java


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