I'm using the code below to open Facebook share dialog with a Facebook page URL.
The problem is, when I look to the shared post on my wall via Facebook application, I find the post without the shared page cover.
While if I shared the same page via Facebook application on my wall, I find the post with the shared page cover (Which of course is much cooler).
Is there a missing parameters in the code below?
I'm using Facebook SDK 4.1.2
FacebookDialog shareDialog = new ShareDialog(mMainActivity);
if (ShareDialog.canShow(ShareLinkContent.class))
{
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse(aFacebookPageURL))
.build();
shareDialog.show(linkContent);
}
Edit 1:
using .setImageUrl(Uri.parse(aPageCoverURL))
You can see the difference between the upper half (shared via Facebook app for mobile) and the bottom half (shared via my application).
Edit 2: How can I use the code below to share a Facebook page? The code below is not working and no share dialog appears, I don't know if there is a missing parameters or this code is not meant to share pages, but I'm trying.
ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
.putString("og:type", "page")
.putString("og:title", aTitle)
.putString("og:url", aURL)
.build();
// Create an action
ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
.setActionType(null)
.putObject("page", object)
.build();
ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
.setPreviewPropertyName("page")
.setAction(action)
.build();
ShareDialog.show(mMainActivity, content);
From the Facebook documentation:
Links
When people share links from your app to Facebook, it includes attributes that show up in the post:
- a contentURL, the link to be shared
- a contentTitle that represents the title of the content in the link
- a imageURL, the URL of thumbnail image that will appear on the post
- a contentDescription of the content, usually 2-4 sentences
If you want to display the image you should use setImageUrl(@Nullable final Uri imageUrl):
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse(aFacebookPageURL))
.setImageUrl(Uri.parse(imageUrl))
.build();
This is a share from SDK:
This is a share directly from the app:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With