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


Java GraphResponse.getError方法代碼示例

本文整理匯總了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();
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:27,代碼來源:Utility.java

示例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);
}
 
開發者ID:Microsoft,項目名稱:EmbeddedSocial-Android-SDK,代碼行數:23,代碼來源:FacebookFriendlistLoader.java

示例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);
            }
        }
    }
}
 
開發者ID:WassimBenltaief,項目名稱:ReactiveFB,代碼行數:24,代碼來源:RequestAction.java

示例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());
            }
        }
    };
}
 
開發者ID:JimRoid,項目名稱:EasyFacebook,代碼行數:19,代碼來源:FacebookTool.java

示例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;
}
 
開發者ID:JimRoid,項目名稱:EasyFacebook,代碼行數:24,代碼來源:FacebookTool.java

示例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);
    }
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:16,代碼來源:ShareInternalUtility.java

示例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));
    }
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:30,代碼來源:VideoUploader.java

示例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);
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:44,代碼來源:LoginClient.java

示例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();
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:16,代碼來源:Utility.java

示例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));

    }
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:34,代碼來源:FacebookShield.java

示例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();
    }
}
 
開發者ID:Turistforeningen,項目名稱:SjekkUT,代碼行數:11,代碼來源:CheckinAndSocialView.java

示例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));
    }
}
 
開發者ID:yudiandreanp,項目名稱:SocioBlood,代碼行數:30,代碼來源:VideoUploader.java

示例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);
    }
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:69,代碼來源:ShareApi.java

示例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;
        }
    }
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:61,代碼來源:AppEventsLogger.java

示例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);
    }
}
 
開發者ID:CE-KMITL-OOAD-2015,項目名稱:Move-Alarm_ORCA,代碼行數:59,代碼來源:ShareApi.java


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