當前位置: 首頁>>代碼示例>>Java>>正文


Java GraphRequest.GraphJSONObjectCallback方法代碼示例

本文整理匯總了Java中com.facebook.GraphRequest.GraphJSONObjectCallback方法的典型用法代碼示例。如果您正苦於以下問題:Java GraphRequest.GraphJSONObjectCallback方法的具體用法?Java GraphRequest.GraphJSONObjectCallback怎麽用?Java GraphRequest.GraphJSONObjectCallback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.facebook.GraphRequest的用法示例。


在下文中一共展示了GraphRequest.GraphJSONObjectCallback方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: DefaultGraphJSONObjectCallback

import com.facebook.GraphRequest; //導入方法依賴的package包/類
private GraphRequest.GraphJSONObjectCallback DefaultGraphJSONObjectCallback(final Callback callback) {
    return new GraphRequest.GraphJSONObjectCallback() {
        @Override
        public void onCompleted(JSONObject jsonObject, GraphResponse graphResponse) {
            if (graphResponse.getError() != null) {
                callback.fail();
                if (isDebug) {

                }
            } else {
                if (isDebug) {

                }
                callback.complete(graphResponse, graphResponse.getJSONObject());
            }
        }
    };
}
 
開發者ID:JimRoid,項目名稱:EasyFacebook,代碼行數:19,代碼來源:FacebookTool.java

示例2: getUserInfo

import com.facebook.GraphRequest; //導入方法依賴的package包/類
private void getUserInfo(LoginResult result) {
    GraphRequest.GraphJSONObjectCallback callback = new GraphRequest.GraphJSONObjectCallback() {
        @Override
        public void onCompleted(JSONObject object, GraphResponse response) {
            if (object == null) {
                responseListener.onResult(SocialType.FACEBOOK, ResultType.FAILURE, null);
                return;
            }

            String id = RichUtils.getJSONString(object, "id");
            String name = RichUtils.getJSONString(object, "name");
            String email = RichUtils.getJSONString(object, "email");
            String gender = RichUtils.getJSONString(object, "gender");
            JSONObject data = RichUtils.getJSONObject(RichUtils.getJSONObject(object, "picture"), "data");
            String profilePicture = RichUtils.getJSONString(data, "url");

            Map<UserInfoType, String> userInfoMap = new HashMap<>();
            userInfoMap.put(UserInfoType.ID, id);
            userInfoMap.put(UserInfoType.NAME, name);
            userInfoMap.put(UserInfoType.EMAIL, email);
            userInfoMap.put(UserInfoType.PROFILE_PICTURE, profilePicture);
            userInfoMap.put(UserInfoType.GENDER, gender);

            responseListener.onResult(SocialType.FACEBOOK, ResultType.SUCCESS, userInfoMap);
        }
    };

    GraphRequest request = GraphRequest.newMeRequest(result.getAccessToken(), callback);
    Bundle parameters = new Bundle();
    parameters.putString("fields",  "id, name, email, gender, birthday, picture");
    request.setParameters(parameters);
    request.executeAsync();
}
 
開發者ID:WindSekirun,項目名稱:SocialLogin,代碼行數:34,代碼來源:FacebookLogin.java


注:本文中的com.facebook.GraphRequest.GraphJSONObjectCallback方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。