use of com.facebook.FacebookException in project facebook-android-sdk by facebook.
the class WebDialog method sendErrorToListener.
protected void sendErrorToListener(Throwable error) {
if (onCompleteListener != null && !listenerCalled) {
listenerCalled = true;
FacebookException facebookException;
if (error instanceof FacebookException) {
facebookException = (FacebookException) error;
} else {
facebookException = new FacebookException(error);
}
onCompleteListener.onComplete(null, facebookException);
dismiss();
}
}
use of com.facebook.FacebookException in project facebook-android-sdk by facebook.
the class CustomTabLoginMethodHandler method onCustomTabComplete.
private void onCustomTabComplete(String url, LoginClient.Request request) {
if (url != null && url.startsWith(CustomTabMainActivity.getRedirectUrl())) {
Uri uri = Uri.parse(url);
Bundle values = Utility.parseUrlQueryString(uri.getQuery());
values.putAll(Utility.parseUrlQueryString(uri.getFragment()));
if (!validateChallengeParam(values)) {
super.onComplete(request, null, new FacebookException("Invalid state parameter"));
return;
}
String error = values.getString("error");
if (error == null) {
error = values.getString("error_type");
}
String errorMessage = values.getString("error_msg");
if (errorMessage == null) {
errorMessage = values.getString("error_message");
}
if (errorMessage == null) {
errorMessage = values.getString("error_description");
}
String errorCodeString = values.getString("error_code");
int errorCode = FacebookRequestError.INVALID_ERROR_CODE;
if (!Utility.isNullOrEmpty(errorCodeString)) {
try {
errorCode = Integer.parseInt(errorCodeString);
} catch (NumberFormatException ex) {
errorCode = FacebookRequestError.INVALID_ERROR_CODE;
}
}
if (Utility.isNullOrEmpty(error) && Utility.isNullOrEmpty(errorMessage) && errorCode == FacebookRequestError.INVALID_ERROR_CODE) {
super.onComplete(request, values, null);
} else if (error != null && (error.equals("access_denied") || error.equals("OAuthAccessDeniedException"))) {
super.onComplete(request, null, new FacebookOperationCanceledException());
} else if (errorCode == API_EC_DIALOG_CANCEL) {
super.onComplete(request, null, new FacebookOperationCanceledException());
} else {
FacebookRequestError requestError = new FacebookRequestError(errorCode, error, errorMessage);
super.onComplete(request, null, new FacebookServiceException(requestError, errorMessage));
}
}
}
use of com.facebook.FacebookException in project facebook-android-sdk by facebook.
the class DialogPresenter method setupAppCallForNativeDialog.
public static void setupAppCallForNativeDialog(AppCall appCall, ParameterProvider parameterProvider, DialogFeature feature) {
Context context = FacebookSdk.getApplicationContext();
String action = feature.getAction();
NativeProtocol.ProtocolVersionQueryResult protocolVersionResult = getProtocolVersionForNativeDialog(feature);
int protocolVersion = protocolVersionResult.getProtocolVersion();
if (protocolVersion == NativeProtocol.NO_PROTOCOL_AVAILABLE) {
throw new FacebookException("Cannot present this dialog. This likely means that the " + "Facebook app is not installed.");
}
Bundle params;
if (NativeProtocol.isVersionCompatibleWithBucketedIntent(protocolVersion)) {
// Facebook app supports the new bucketed protocol
params = parameterProvider.getParameters();
} else {
// Facebook app only supports the old flat protocol
params = parameterProvider.getLegacyParameters();
}
if (params == null) {
params = new Bundle();
}
Intent intent = NativeProtocol.createPlatformActivityIntent(context, appCall.getCallId().toString(), action, protocolVersionResult, params);
if (intent == null) {
throw new FacebookException("Unable to create Intent; this likely means the" + "Facebook app is not installed.");
}
appCall.setRequestIntent(intent);
}
use of com.facebook.FacebookException in project facebook-android-sdk by facebook.
the class DialogPresenter method setupAppCallForCannotShowError.
public static void setupAppCallForCannotShowError(AppCall appCall) {
FacebookException e = new FacebookException("Unable to show the provided content via the web or the installed version of the " + "Facebook app. Some dialogs are only supported starting API 14.");
setupAppCallForValidationError(appCall, e);
}
use of com.facebook.FacebookException in project facebook-android-sdk by facebook.
the class GraphUtil method createOpenGraphObjectForPost.
/**
* Creates a JSONObject for an open graph object that is suitable for posting.
* @param type the Open Graph object type for the object, or null if it will be specified later
* @param title the title of the object, or null if it will be specified later
* @param imageUrl the URL of an image associated with the object, or null
* @param url the URL associated with the object, or null
* @param description the description of the object, or null
* @param objectProperties the properties of the open graph object
* @param id the id of the object if the post is for update
* @return a JSONObject
*/
public static JSONObject createOpenGraphObjectForPost(String type, String title, String imageUrl, String url, String description, JSONObject objectProperties, String id) {
JSONObject openGraphObject = new JSONObject();
try {
if (type != null) {
openGraphObject.put("type", type);
}
openGraphObject.put("title", title);
if (imageUrl != null) {
JSONObject imageUrlObject = new JSONObject();
imageUrlObject.put("url", imageUrl);
JSONArray imageUrls = new JSONArray();
imageUrls.put(imageUrlObject);
openGraphObject.put("image", imageUrls);
}
openGraphObject.put("url", url);
openGraphObject.put("description", description);
openGraphObject.put(NativeProtocol.OPEN_GRAPH_CREATE_OBJECT_KEY, true);
if (objectProperties != null) {
openGraphObject.put("data", objectProperties);
}
if (id != null) {
openGraphObject.put("id", id);
}
} catch (JSONException e) {
throw new FacebookException("An error occurred while setting up the graph object", e);
}
return openGraphObject;
}
Aggregations