my problem is that i am not able to see content title and content description of my sharing image using facebook share in android app.
my code is
if (shareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("Content Title")
.setImageUrl(Uri.parse(getIntent().getStringExtra("shareValue")))
.setContentDescription("Content Description")
.build();
shareDialog.show(linkContent); // Show facebook ShareDialog
}
sharing those parameters has been disabled in Facebook graph API
Modeling content
Related
Is there any way to share image and link on facebook in android. I tried below code without success.
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("Test")
.setContentDescription("Simple Test")
.setContentUrl(Uri.parse("https://material.io/icons/"))
.setImageUrl(Uri.parse("https://data.kaktus.media/file/file/2017-12-08_16-29-44_928522.jpg"))
.build();
AFAIK setImageUrl is now deprecated. The problem is the ImageUrl image is replaced by the ContentUrl image as mentioned in this question FaceBook ShareLinkContent setImageUrl is replaced by ContentUrl metadata in android.
I am developing an Android app. In my app, I am integrating Facebook API because I am sharing content from my app to Facebook. I am especially sharing link. So I am using ShareLinkContent option from official Facebook docs. I can successfully share on Facebook. But I am having a problem with this ShareLinkContent option because I cannot set the caption to post that is entered by user.
This is how I share to Facebook:
final ShareLinkContent content = new ShareLinkContent.Builder()
.setContentTitle(shareTitle)
.setImageUrl(Uri.parse(shareImageUrl))
.setContentUrl(Uri.parse(shareContentUrl))
.setContentDescription(shareDescription)
.build();
ShareApi.share(content, null);
I display preview before I share like this:
As you can see now, I can only show preview. But what I want is I want to add an EditText in the preview. The text entered will be shared as post caption on Facebook. But the problem is there is no option setCaption(textUserEntered) in the ShareLinkContent option. I also mentioned options available in the preview image as well.
How can I set post option for ShareLinkContent? That content will be entered by user. How can I get it? Is it possible to use with ShareLinkContent?
I found the solution. Actually I do not need to show custom preview to user. If I build the share content like below code, preview will the option to enter post caption will be automatically added.
final ShareLinkContent content = new ShareLinkContent.Builder()
.setContentTitle(shareTitle)
.setImageUrl(Uri.parse(shareImageUrl))
.setContentUrl(Uri.parse(shareContentUrl))
.setContentDescription(shareDescription)
.build();
ShareDialog shareDialog = new ShareDialog(this);
shareDialog.show(content);
So no need to use
ShareApi.share(content, null);
I am working on an app that I want to be able to post to Facebook wall. The language used for the app is non-latin based character set. Hence, the user types the content to share using the app itself and then share it on facebook without going to the ShareDialog as the content is already typed. I am using Facebook SDK for Android 4.+. Can anyone help me on doing this? All example I got is posting using ShareDialog. Facebook SDK seems to have classes like ShareLinkContent, SharePhoto, ShareMedia but no class to attach simple text content which I am trying to do. Or, can I make the content already typed appear on the ShareDialog's EditText?
Facebook does not allow you to pre-fill the ShareDialog's text. As far as I know there also is no other way to post content on a user's wall.
What is possible is share a link using the ShareDialog, and you can pre-fill the link description and other attributes like image and title but I guess that's not what you want.
An example of that is:
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentDescription(descriptionString)
.setContentUrl(Uri.parse(urlString))
.setImageUrl(Uri.parse(pictureUrlString))
.setContentTitle(titleString)
.build();
ShareDialog dialog = new ShareDialog(this);
dialog.show(content);
private void showFacebookShareDialog() {
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("Title")
.setContentDescription(
"Share Text")
.setContentUrl(Uri.parse("http://developers.facebook.com/android"))
.build();
shareDialog.show(linkContent);
}
}
When I share link with referrer, Facebook SDK (v4.8) will remove it from link.
For example I have following link:
https://play.google.com/store/apps/details?id=com.mypackage.myapp&referrer=utm_source%3Dfacebook
The actual post on wall contains link without referrer:
http://play.google.com/store/apps/details?id=com.mypackage.myapp
Code:
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse("https://play.google.com/store/apps/details?id=com.mypackage.myapp&referrer=utm_source%3Dfacebook"))
.build();
shareDialog.show(content);
}
Is there a way to add message to the ShareDialog when using ShareLinkContent in android application. Using Facebook sdk 4.0. I am using this code
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("XXXXX")
.setContentDescription(
"XXXXX in real time")
.setContentUrl(Uri.parse("http://play.google.com/store/apps/details?id=" + getApplicationContext().getPackageName()))
.build();
shareDialog.show(linkContent);
Use:
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentUrl(yourUrl)
.build();
ShareApi shareApi = new ShareApi(content);
shareApi.setMessage(message);
shareApi.share(facebookCallback);
No, there's no message property on ShareLinkContent because it's supposed to represent the content itself (i.e. the link), and not what the user's message would be.
If you use the Graph API directly to post with publish_actions permissions, then you can attach a message to the ShareApi class.
If you use the ShareDialog class, then the user is prompted to type in a message, and you won't have the ability to set one.