Home Sharing image with caption in facebook using facebook share button only shares image
Reply: 1

Sharing image with caption in facebook using facebook share button only shares image

Pritom Mazumdar
1#
Pritom Mazumdar Published in 2018-02-10 06:29:00Z

I am building an application in which user can share an image with a message/caption using the share button inside the application which I have implemented from [facebook docs][1]. The problem is that the image gets shared but the message/caption doesn't.

The code is given below :

MainActivity.java

(inside onCreate method)

shareButton=(Button) findViewById(R.id.shareButton);
    shareDialog=new ShareDialog(this);
    shareButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //selectedContentShare();
            Toast.makeText(getApplicationContext(),"Clicked share",Toast.LENGTH_LONG).show();
            sharePost(imagePost,temp);
            Toast.makeText(getApplicationContext(),temp,Toast.LENGTH_LONG).show();
        }
});

Here imagePost is the image to be shared and temp is the message/caption. I have used a Toast message to check whether temp is null or not but it is not null.

As specified in the facebook docs I have implemented the functionality of the share button. The code is given below :

(outside onCreate method)

public void sharePost(Bitmap imagePost,String temp){
    SharePhoto photo=new SharePhoto.Builder()
            .setBitmap(imagePost)
            .setCaption(temp)
            .build();
    SharePhotoContent content=new SharePhotoContent.Builder()
            .addPhoto(photo)
            .build();
    shareDialog.show(content);
}

Here imagePost is the image to be shared and temp is the message/caption.

[Updated]

The facebook docs which I followed for posting the image with caption, I followed the same for a link to a website with a quote and it gets posted, but image with any texts doesn't get posted. The code is given below :

public void sharePost(){
    if (ShareDialog.canShow(ShareLinkContent.class)) {
        ShareLinkContent linkContent = new ShareLinkContent.Builder()
                .setQuote("quote")
                .build();
        shareDialog.show(linkContent);
    }
}

Can anyone explain and help me as to why the caption is not being shared

Son Nguyen
2#
Son Nguyen Reply to 2018-02-10 08:39:01Z

I think setCaption might be deprecated.

When you implement sharing, your app should not pre-fill any content to be shared. This is inconsistent with Facebook Platform Policy, see Facebook Platform Policy, 2.3

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.335825 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO