本文整理汇总了Java中com.facebook.GraphResponse.getError方法的典型用法代码示例。如果您正苦于以下问题:Java GraphResponse.getError方法的具体用法?Java GraphResponse.getError怎么用?Java GraphResponse.getError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.GraphResponse
的用法示例。
在下文中一共展示了GraphResponse.getError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getGraphMeRequestWithCacheAsync
import com.facebook.GraphResponse; //导入方法依赖的package包/类
public static void getGraphMeRequestWithCacheAsync(
final String accessToken,
final GraphMeRequestWithCacheCallback callback) {
JSONObject cachedValue = ProfileInformationCache.getProfileInformation(accessToken);
if (cachedValue != null) {
callback.onSuccess(cachedValue);
return;
}
GraphRequest.Callback graphCallback = new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
if (response.getError() != null) {
callback.onFailure(response.getError().getException());
} else {
ProfileInformationCache.putProfileInformation(
accessToken,
response.getJSONObject());
callback.onSuccess(response.getJSONObject());
}
}
};
GraphRequest graphRequest = getGraphMeRequestWithCache(accessToken);
graphRequest.setCallback(graphCallback);
graphRequest.executeAsync();
}
示例2: getThirdPartyFriendIds
import com.facebook.GraphResponse; //导入方法依赖的package包/类
@Override
public List<String> getThirdPartyFriendIds() throws SocialNetworkException {
if (!isAuthorizedToSocialNetwork()) {
throw new NotAuthorizedToSocialNetworkException();
}
GraphResponse response = new GraphRequest(
facebookTokenHolder.getToken(),
FACEBOOK_FRIENDS_GRAPH_PATH,
Bundle.EMPTY,
HttpMethod.GET
).executeAndWait();
facebookTokenHolder.clearToken();
FacebookRequestError responseError = response.getError();
if (responseError != null) {
throw new SocialNetworkException("Internal facebook failure: "
+ responseError.getErrorMessage() + " [" + responseError.getErrorCode() + "]");
}
return extractFacebookFriendIds(response);
}
示例3: onCompleted
import com.facebook.GraphResponse; //导入方法依赖的package包/类
@Override
public void onCompleted(GraphResponse response) {
FacebookRequestError error = response.getError();
if (error != null) {
Logger.logError(RequestAction.class,
"Failed to get what you have requested", error.getException());
if (mSingleEmitter != null) {
mSingleEmitter.onError(error.getException());
}
} else {
if (response.getRawResponse() == null) {
Logger.logError(RequestAction.class, "The response GraphObject " +
"has null value. Response=" + response.toString(), null);
mSingleEmitter.onError(new FacebookGraphResponseException(response,
"The response has null value"));
} else {
if (mSingleEmitter != null) {
mSingleEmitter.onSuccess(response);
}
}
}
}
示例4: DefaultGraphJSONObjectCallback
import com.facebook.GraphResponse; //导入方法依赖的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());
}
}
};
}
示例5: DefaultCallback
import com.facebook.GraphResponse; //导入方法依赖的package包/类
/**
* @param callback
* @return
*/
private GraphRequest.Callback DefaultCallback(final Callback callback) {
GraphRequest.Callback GraphRequestcallback = new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse graphResponse) {
if (graphResponse.getError() != null) {
callback.fail();
if (isDebug) {
}
} else {
if (isDebug) {
}
callback.complete(graphResponse, graphResponse.getJSONObject());
}
}
};
return GraphRequestcallback;
}
示例6: invokeCallbackWithResults
import com.facebook.GraphResponse; //导入方法依赖的package包/类
public static void invokeCallbackWithResults(
FacebookCallback<Sharer.Result> callback,
final String postId,
final GraphResponse graphResponse) {
FacebookRequestError requestError = graphResponse.getError();
if (requestError != null) {
String errorMessage = requestError.getErrorMessage();
if (Utility.isNullOrEmpty(errorMessage)) {
errorMessage = "Unexpected error sharing.";
}
invokeOnErrorCallback(callback, graphResponse, errorMessage);
} else {
invokeOnSuccessCallback(callback, postId);
}
}
示例7: executeGraphRequestSynchronously
import com.facebook.GraphResponse; //导入方法依赖的package包/类
protected void executeGraphRequestSynchronously(Bundle parameters) {
GraphRequest request = new GraphRequest(
uploadContext.accessToken,
String.format(Locale.ROOT, "%s/videos", uploadContext.graphNode),
parameters,
HttpMethod.POST,
null);
GraphResponse response = request.executeAndWait();
if (response != null) {
FacebookRequestError error = response.getError();
JSONObject responseJSON = response.getJSONObject();
if (error != null) {
if (!attemptRetry(error.getSubErrorCode())) {
handleError(new FacebookGraphResponseException(response, ERROR_UPLOAD));
}
} else if (responseJSON != null) {
try {
handleSuccess(responseJSON);
} catch (JSONException e) {
endUploadWithFailure(new FacebookException(ERROR_BAD_SERVER_RESPONSE, e));
}
} else {
handleError(new FacebookException(ERROR_BAD_SERVER_RESPONSE));
}
} else {
handleError(new FacebookException(ERROR_BAD_SERVER_RESPONSE));
}
}
示例8: handlePermissionResponse
import com.facebook.GraphResponse; //导入方法依赖的package包/类
/**
* This parses a server response to a call to me/permissions. It will return the list of
* granted permissions. It will optionally update an access token with the requested permissions.
*
* @param response The server response
* @return A list of granted permissions or null if an error
*/
private static PermissionsPair handlePermissionResponse(GraphResponse response) {
if (response.getError() != null) {
return null;
}
JSONObject result = response.getJSONObject();
if (result == null) {
return null;
}
JSONArray data = result.optJSONArray("data");
if (data == null || data.length() == 0) {
return null;
}
List<String> grantedPermissions = new ArrayList<String>(data.length());
List<String> declinedPermissions = new ArrayList<String>(data.length());
for (int i = 0; i < data.length(); ++i) {
JSONObject object = data.optJSONObject(i);
String permission = object.optString("permission");
if (permission == null || permission.equals("installed")) {
continue;
}
String status = object.optString("status");
if (status == null) {
continue;
}
if(status.equals("granted")) {
grantedPermissions.add(permission);
} else if (status.equals("declined")) {
declinedPermissions.add(permission);
}
}
return new PermissionsPair(grantedPermissions, declinedPermissions);
}
示例9: awaitGetGraphMeRequestWithCache
import com.facebook.GraphResponse; //导入方法依赖的package包/类
public static JSONObject awaitGetGraphMeRequestWithCache(
final String accessToken) {
JSONObject cachedValue = ProfileInformationCache.getProfileInformation(accessToken);
if (cachedValue != null) {
return cachedValue;
}
GraphRequest graphRequest = getGraphMeRequestWithCache(accessToken);
GraphResponse response = graphRequest.executeAndWait();
if (response.getError() != null) {
return null;
}
return response.getJSONObject();
}
示例10: publishStory
import com.facebook.GraphResponse; //导入方法依赖的package包/类
private void publishStory(final String message) {
if (AccessToken.getCurrentAccessToken() != null) {
Bundle postParams = new Bundle();
postParams.putString("message", message);
GraphRequest.Callback callback = new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse graphResponse) {
FacebookRequestError error = graphResponse.getError();
if (error != null) {
if (eventHandler != null) {
Log.sysOut("$#$#$ " + error);
eventHandler.stopProgress();
eventHandler.onFacebookError(error
.getErrorMessage());
}
return;
}
if (eventHandler != null) {
eventHandler.stopProgress();
eventHandler.onRecievePost(message);
}
}
};
GraphRequest request = new GraphRequest(AccessToken.getCurrentAccessToken(), "feed", postParams,
HttpMethod.POST, callback);
request.executeAsync();
} else if (eventHandler != null) eventHandler.onFacebookError(activity.getString(R.string.facebook_you_must_login_first_toast));
}
示例11: onCompleted
import com.facebook.GraphResponse; //导入方法依赖的package包/类
@Override
public void onCompleted(GraphResponse response) {
if (response.getError() == null && response.getJSONObject() != null && response.getJSONObject().has("id")) {
mAppLink = "https://fb.me/" + response.getJSONObject().opt("id");
updateView();
} else {
mAppLink = null;
updateView();
}
}
示例12: executeGraphRequestSynchronously
import com.facebook.GraphResponse; //导入方法依赖的package包/类
protected void executeGraphRequestSynchronously(Bundle parameters) {
GraphRequest request = new GraphRequest(
uploadContext.accessToken,
String.format(Locale.ROOT, "%s/videos", uploadContext.targetId),
parameters,
HttpMethod.POST,
null);
GraphResponse response = request.executeAndWait();
if (response != null) {
FacebookRequestError error = response.getError();
JSONObject responseJSON = response.getJSONObject();
if (error != null) {
if (!attemptRetry(error.getSubErrorCode())) {
handleError(new FacebookGraphResponseException(response, ERROR_UPLOAD));
}
} else if (responseJSON != null) {
try {
handleSuccess(responseJSON);
} catch (JSONException e) {
endUploadWithFailure(new FacebookException(ERROR_BAD_SERVER_RESPONSE, e));
}
} else {
handleError(new FacebookException(ERROR_BAD_SERVER_RESPONSE));
}
} else {
handleError(new FacebookException(ERROR_BAD_SERVER_RESPONSE));
}
}
示例13: sharePhotoContent
import com.facebook.GraphResponse; //导入方法依赖的package包/类
private void sharePhotoContent(final SharePhotoContent photoContent,
final FacebookCallback<Sharer.Result> callback) {
final Mutable<Integer> requestCount = new Mutable<Integer>(0);
final AccessToken accessToken = AccessToken.getCurrentAccessToken();
final ArrayList<GraphRequest> requests = new ArrayList<GraphRequest>();
final ArrayList<JSONObject> results = new ArrayList<JSONObject>();
final ArrayList<GraphResponse> errorResponses = new ArrayList<GraphResponse>();
final GraphRequest.Callback requestCallback = new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
final JSONObject result = response.getJSONObject();
if (result != null) {
results.add(result);
}
if (response.getError() != null) {
errorResponses.add(response);
}
requestCount.value -= 1;
if (requestCount.value == 0) {
if (!errorResponses.isEmpty()) {
ShareInternalUtility.invokeCallbackWithResults(
callback,
null,
errorResponses.get(0));
} else if (!results.isEmpty()) {
final String postId = results.get(0).optString("id");
ShareInternalUtility.invokeCallbackWithResults(
callback,
postId,
response);
}
}
}
};
try {
for (SharePhoto photo : photoContent.getPhotos()) {
final Bitmap bitmap = photo.getBitmap();
final Uri photoUri = photo.getImageUrl();
String caption = photo.getCaption();
if (caption == null) {
caption = this.getMessage();
}
if (bitmap != null) {
requests.add(GraphRequest.newUploadPhotoRequest(
accessToken,
getGraphPath(PHOTOS_EDGE),
bitmap,
caption,
photo.getParameters(),
requestCallback));
} else if (photoUri != null) {
requests.add(GraphRequest.newUploadPhotoRequest(
accessToken,
getGraphPath(PHOTOS_EDGE),
photoUri,
caption,
photo.getParameters(),
requestCallback));
}
}
requestCount.value += requests.size();
for (GraphRequest request : requests) {
request.executeAsync();
}
} catch (final FileNotFoundException ex) {
ShareInternalUtility.invokeCallbackWithException(callback, ex);
}
}
示例14: handleResponse
import com.facebook.GraphResponse; //导入方法依赖的package包/类
private static void handleResponse(
AccessTokenAppIdPair accessTokenAppId,
GraphRequest request,
GraphResponse response,
SessionEventsState sessionEventsState,
FlushStatistics flushState) {
FacebookRequestError error = response.getError();
String resultDescription = "Success";
FlushResult flushResult = FlushResult.SUCCESS;
if (error != null) {
final int NO_CONNECTIVITY_ERROR_CODE = -1;
if (error.getErrorCode() == NO_CONNECTIVITY_ERROR_CODE) {
resultDescription = "Failed: No Connectivity";
flushResult = FlushResult.NO_CONNECTIVITY;
} else {
resultDescription = String.format("Failed:\n Response: %s\n Error %s",
response.toString(),
error.toString());
flushResult = FlushResult.SERVER_ERROR;
}
}
if (FacebookSdk.isLoggingBehaviorEnabled(LoggingBehavior.APP_EVENTS)) {
String eventsJsonString = (String) request.getTag();
String prettyPrintedEvents;
try {
JSONArray jsonArray = new JSONArray(eventsJsonString);
prettyPrintedEvents = jsonArray.toString(2);
} catch (JSONException exc) {
prettyPrintedEvents = "<Can't encode events for debug logging>";
}
Logger.log(LoggingBehavior.APP_EVENTS, TAG,
"Flush completed\nParams: %s\n Result: %s\n Events JSON: %s",
request.getGraphObject().toString(),
resultDescription,
prettyPrintedEvents);
}
sessionEventsState.clearInFlightAndStats(error != null);
if (flushResult == FlushResult.NO_CONNECTIVITY) {
// We may call this for multiple requests in a batch, which is slightly inefficient
// since in principle we could call it once for all failed requests, but the impact is
// likely to be minimal. We don't call this for other server errors, because if an event
// failed because it was malformed, etc., continually retrying it will cause subsequent
// events to not be logged either.
PersistedEvents.persistEvents(applicationContext, accessTokenAppId, sessionEventsState);
}
if (flushResult != FlushResult.SUCCESS) {
// We assume that connectivity issues are more significant to report than server issues.
if (flushState.result != FlushResult.NO_CONNECTIVITY) {
flushState.result = flushResult;
}
}
}
示例15: sharePhotoContent
import com.facebook.GraphResponse; //导入方法依赖的package包/类
private void sharePhotoContent(final SharePhotoContent photoContent,
final FacebookCallback<Sharer.Result> callback) {
final Mutable<Integer> requestCount = new Mutable<Integer>(0);
final AccessToken accessToken = AccessToken.getCurrentAccessToken();
final ArrayList<GraphRequest> requests = new ArrayList<GraphRequest>();
final ArrayList<JSONObject> results = new ArrayList<JSONObject>();
final ArrayList<GraphResponse> errorResponses = new ArrayList<GraphResponse>();
final GraphRequest.Callback requestCallback = new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
final JSONObject result = response.getJSONObject();
if (result != null) {
results.add(result);
}
if (response.getError() != null) {
errorResponses.add(response);
}
requestCount.value -= 1;
if (requestCount.value == 0) {
if (!errorResponses.isEmpty()) {
ShareInternalUtility.invokeCallbackWithResults(
callback,
null,
errorResponses.get(0));
} else if (!results.isEmpty()) {
final String postId = results.get(0).optString("id");
ShareInternalUtility.invokeCallbackWithResults(
callback,
postId,
response);
}
}
}
};
try {
for (SharePhoto photo : photoContent.getPhotos()) {
final Bitmap bitmap = photo.getBitmap();
final Uri photoUri = photo.getImageUrl();
if (bitmap != null) {
requests.add(ShareInternalUtility.newUploadPhotoRequest(
accessToken,
bitmap,
requestCallback));
} else if (photoUri != null) {
requests.add(ShareInternalUtility.newUploadPhotoRequest(
accessToken,
photoUri,
requestCallback));
}
}
requestCount.value += requests.size();
for (GraphRequest request : requests) {
request.executeAsync();
}
} catch (final FileNotFoundException ex) {
ShareInternalUtility.invokeCallbackWithException(callback, ex);
}
}