How to share image on Facebook with Caption from android? - android

I tried sharing an Image with Caption on Facebook with the help of Facebook API and the code as below:
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(image)
.setCaption("Caption is Important")
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
shareDialog.show(content);
It open up the ShareDialog but the caption wont appear in it the dialog

As per the facebook documentation shared CBroe:
https://developers.facebook.com/policy#control
According to its policy 2.3 it states that
Don't prefill captions, comments, messages, or the user message parameter of posts with content a person or business didn’t create, even if the person can edit or remove the content before sharing. You may use our Share Dialogs to prefill a single hashtag in a post, but don't prefill any content a person or business didn't create via the API.
So we are no longer allowed to pre-fill captions for images by using shareDialog or by using any other method.

You can add caption with the given method. But at share dialog of facebook. You have to manually type your caption.

Related

android facebook sdk setcaption not working

I am trying to share a photo with caption and link from my android app to facebook, my photo is uploaded to facebook but caption is not updating Here is my code
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.image);
SharePhoto sharePhoto1 = new SharePhoto.Builder()
.setBitmap(bitmap)
.setCaption("This is a Beautiful Picture")
.build();
ShareContent shareContent = new ShareMediaContent.Builder()
.addMedium(sharePhoto1)
.setPageId("132583174018394")
.build();
shareDialog.show(shareContent);
I was trying to do something similar and noticed that the setCaption() method did not work. Take a look at the android facebook sdk documentation in this link, and read the getCaption() method description:
"https://developers.facebook.com/docs/reference/android/current/class/SharePhoto/"
"Gets the user generated caption. Note that the 'caption' must come from the user, as pre-filled content is forbidden by the Platform Policies (2.3)."

How to set post caption in Facebook Share using ShareLinkContent 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);

How to set description or title to Facebook photo share with PhotoShareContent in Android

I am developing an Android app. In my app, I am integrating Facebook photo share feature. This is my first Android app with Facebook integration. I am able to share photo to user timeline now. But I am having problem with setting description to that image.
This is my Facebook share photo function
private void sharePhotoToFacebook(){
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(shareBitmap)
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
ShareApi.share(content, null);
}
When photo shared it shows like this in timeline
As you can see there is no description or title. What I want is I want to set title or description. Is there any function can do like below
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo).setCaption("Description")
.build();
How can I set title?
Write setCaption() method as below:
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(shareBitmap)
.setCaption("Description")
.build();
Note: need to use SDK vertion 4+. Means at least 4.1
compile 'com.facebook.android:facebook-android-sdk:4.+'
As per Facebook Platform Policies (2.3) you cannot set caption from your app. Read this note from documentation.
setCaption(String)
Sets the user generated caption for the photo. Note that the 'caption' must come from the user, as pre-filled content is forbidden by the Platform Policies (2.3).

How to share photos on facebook with android programmatically

I follow facebook's tutorial and I want to share my application screen shot so i used code on below.But it didn't also i can be log in.
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(bm)
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
ShareDialog shareDialog1 = new ShareDialog(Oyun.this);
shareDialog1.show(content);
Please visit this answer given by this guy he share photos as well as include caption with it
How to share photo with CAPTION via Android share intent on Facebook?
You need to make a simple intent to Facebook for it and you can share it. Just go through the above answer and you will find it out very easy.

Android Facebook Share Photo with Text as Link

Facebook SDK keeps on changing, and I would like to know how to upload a photo (when sharing) with separate text (not embedded).
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(newBitmap)
.setUserGenerated(true)
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
ShareDialog.show(Main.this, content);
Is there a way to put the text after the photo, or even have the share message (where the user can type) pre-filled with some text?
By the way, I'm using the this version of FB:
compile 'com.facebook.android:facebook-android-sdk:4.0.1'
Okay, I understand the down votes now. Not reading the policies (only because I never really do). It states there that:
Don't prefill captions, comments, messages, or the user message parameter of posts with content a person didn’t create, even if the person can edit or remove the content before sharing.
Source: https://developers.facebook.com/policy/
pre-fill text-with-image is no longer work
https://developers.facebook.com/docs/apps/review/prefill

Categories

Resources