本文整理匯總了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();
}