com.facebook.share.model.ShareLinkContent Java Examples
The following examples show how to use
com.facebook.share.model.ShareLinkContent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebDialogParameters.java From kognitivo with Apache License 2.0 | 6 votes |
public static Bundle createForFeed(ShareLinkContent shareLinkContent) { Bundle webParams = new Bundle(); Utility.putNonEmptyString( webParams, ShareConstants.WEB_DIALOG_PARAM_NAME, shareLinkContent.getContentTitle()); Utility.putNonEmptyString( webParams, ShareConstants.WEB_DIALOG_PARAM_DESCRIPTION, shareLinkContent.getContentDescription()); Utility.putNonEmptyString( webParams, ShareConstants.WEB_DIALOG_PARAM_LINK, Utility.getUriString(shareLinkContent.getContentUrl())); Utility.putNonEmptyString( webParams, ShareConstants.WEB_DIALOG_PARAM_PICTURE, Utility.getUriString(shareLinkContent.getImageUrl())); return webParams; }
Example #2
Source File: ShareContentValidation.java From kognitivo with Apache License 2.0 | 6 votes |
private static void validate(ShareContent content, Validator validator) throws FacebookException { if (content == null) { throw new FacebookException("Must provide non-null content to share"); } if (content instanceof ShareLinkContent) { validator.validate((ShareLinkContent) content); } else if (content instanceof SharePhotoContent) { validator.validate((SharePhotoContent) content); } else if (content instanceof ShareVideoContent) { validator.validate((ShareVideoContent) content); } else if (content instanceof ShareOpenGraphContent) { validator.validate((ShareOpenGraphContent) content); } }
Example #3
Source File: SocialSharePlugin.java From social_share_plugin with BSD 2-Clause "Simplified" License | 5 votes |
private void facebookShareLink(String quote, String url) { final Uri uri = Uri.parse(url); final ShareLinkContent content = new ShareLinkContent.Builder().setContentUrl(uri).setQuote(quote).build(); final ShareDialog shareDialog = new ShareDialog(activity); shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() { @Override public void onSuccess(Sharer.Result result) { channel.invokeMethod("onSuccess", null); Log.d("SocialSharePlugin", "Sharing successfully done."); } @Override public void onCancel() { channel.invokeMethod("onCancel", null); Log.d("SocialSharePlugin", "Sharing cancelled."); } @Override public void onError(FacebookException error) { channel.invokeMethod("onError", error.getMessage()); Log.d("SocialSharePlugin", "Sharing error occurred."); } }); if (ShareDialog.canShow(ShareLinkContent.class)) { shareDialog.show(content); } }
Example #4
Source File: WebDialogParameters.java From kognitivo with Apache License 2.0 | 5 votes |
public static Bundle create(ShareLinkContent shareLinkContent) { Bundle params = new Bundle(); Utility.putUri( params, ShareConstants.WEB_DIALOG_PARAM_HREF, shareLinkContent.getContentUrl()); return params; }
Example #5
Source File: NativeDialogParameters.java From kognitivo with Apache License 2.0 | 5 votes |
public static Bundle create( UUID callId, ShareContent shareContent, boolean shouldFailOnDataError) { Validate.notNull(shareContent, "shareContent"); Validate.notNull(callId, "callId"); Bundle nativeParams = null; if (shareContent instanceof ShareLinkContent) { final ShareLinkContent linkContent = (ShareLinkContent) shareContent; nativeParams = create(linkContent, shouldFailOnDataError); } else if (shareContent instanceof SharePhotoContent) { final SharePhotoContent photoContent = (SharePhotoContent) shareContent; List<String> photoUrls = ShareInternalUtility.getPhotoUrls( photoContent, callId); nativeParams = create(photoContent, photoUrls, shouldFailOnDataError); } else if (shareContent instanceof ShareVideoContent) { final ShareVideoContent videoContent = (ShareVideoContent) shareContent; String videoUrl = ShareInternalUtility.getVideoUrl(videoContent, callId); nativeParams = create(videoContent, videoUrl, shouldFailOnDataError); } else if (shareContent instanceof ShareOpenGraphContent) { final ShareOpenGraphContent openGraphContent = (ShareOpenGraphContent) shareContent; try { JSONObject openGraphActionJSON = ShareInternalUtility.toJSONObjectForCall( callId, openGraphContent); openGraphActionJSON = ShareInternalUtility.removeNamespacesFromOGJsonObject( openGraphActionJSON, false); nativeParams = create(openGraphContent, openGraphActionJSON, shouldFailOnDataError); } catch (final JSONException e) { throw new FacebookException( "Unable to create a JSON Object from the provided ShareOpenGraphContent: " + e.getMessage()); } } return nativeParams; }
Example #6
Source File: NativeDialogParameters.java From kognitivo with Apache License 2.0 | 5 votes |
private static Bundle create(ShareLinkContent linkContent, boolean dataErrorsFatal) { Bundle params = createBaseParameters(linkContent, dataErrorsFatal); Utility.putNonEmptyString(params, ShareConstants.TITLE, linkContent.getContentTitle()); Utility.putNonEmptyString( params, ShareConstants.DESCRIPTION, linkContent.getContentDescription()); Utility.putUri(params, ShareConstants.IMAGE_URL, linkContent.getImageUrl()); return params; }
Example #7
Source File: ShareContentValidation.java From kognitivo with Apache License 2.0 | 5 votes |
private static void validateLinkContent( ShareLinkContent linkContent, Validator validator) { Uri imageUrl = linkContent.getImageUrl(); if (imageUrl != null && !Utility.isWebUri(imageUrl)) { throw new FacebookException("Image Url must be an http:// or https:// url"); } }
Example #8
Source File: LegacyNativeDialogParameters.java From kognitivo with Apache License 2.0 | 5 votes |
public static Bundle create( UUID callId, ShareContent shareContent, boolean shouldFailOnDataError) { Validate.notNull(shareContent, "shareContent"); Validate.notNull(callId, "callId"); Bundle nativeParams = null; if (shareContent instanceof ShareLinkContent) { final ShareLinkContent linkContent = (ShareLinkContent)shareContent; nativeParams = create(linkContent, shouldFailOnDataError); } else if (shareContent instanceof SharePhotoContent) { final SharePhotoContent photoContent = (SharePhotoContent)shareContent; List<String> photoUrls = ShareInternalUtility.getPhotoUrls( photoContent, callId); nativeParams = create(photoContent, photoUrls, shouldFailOnDataError); } else if (shareContent instanceof ShareVideoContent) { final ShareVideoContent videoContent = (ShareVideoContent)shareContent; nativeParams = create(videoContent, shouldFailOnDataError); } else if (shareContent instanceof ShareOpenGraphContent) { final ShareOpenGraphContent openGraphContent = (ShareOpenGraphContent) shareContent; try { JSONObject openGraphActionJSON = ShareInternalUtility.toJSONObjectForCall( callId, openGraphContent); nativeParams = create(openGraphContent, openGraphActionJSON, shouldFailOnDataError); } catch (final JSONException e) { throw new FacebookException( "Unable to create a JSON Object from the provided ShareOpenGraphContent: " + e.getMessage()); } } return nativeParams; }
Example #9
Source File: LegacyNativeDialogParameters.java From kognitivo with Apache License 2.0 | 5 votes |
private static Bundle create(ShareLinkContent linkContent, boolean dataErrorsFatal) { Bundle params = createBaseParameters(linkContent, dataErrorsFatal); Utility.putNonEmptyString( params, ShareConstants.LEGACY_TITLE, linkContent.getContentTitle()); Utility.putNonEmptyString( params, ShareConstants.LEGACY_DESCRIPTION, linkContent.getContentDescription()); Utility.putUri(params, ShareConstants.LEGACY_IMAGE, linkContent.getImageUrl()); return params; }
Example #10
Source File: FacebookHelper.java From AndroidBlueprints with Apache License 2.0 | 5 votes |
/** * Share content on facebook wall * * @param activity the activity * @param callback the callback to receive a result of this share * @param url the url you wish to share * @param quote the text you wish to associate with the url shared */ private void shareLinkOnFacebook(@NonNull final Activity activity, @NonNull final FacebookShareResultCallback callback, @NonNull String url, @Nullable String quote) { ShareDialog shareDialog = new ShareDialog(activity); shareDialog.registerCallback(mCallbackManager, new FacebookCallback<Sharer.Result>() { @Override public void onSuccess(Sharer.Result result) { callback.onFacebookShareSuccess(result); } @Override public void onCancel() { callback.onFacebookShareCancel(); } @Override public void onError(FacebookException error) { callback.onFacebookShareError(error); } }, RC_FACEBOOK_SHARE); if (ShareDialog.canShow(ShareLinkContent.class)) { ShareLinkContent linkContent = new ShareLinkContent.Builder().setContentUrl(Uri.parse(url)) .setQuote(quote) .build(); shareDialog.show(linkContent); } else { callback.onFacebookShareCannotShowDialog(); } }
Example #11
Source File: ShareContentValidation.java From kognitivo with Apache License 2.0 | 4 votes |
public void validate(final ShareLinkContent linkContent) { validateLinkContent(linkContent, this); }