本文整理汇总了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());
}
}
};
}
示例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();
}