FaceBook ShareLinkContent setImageUrl is replaced by ContentUrl metadata in android

℡╲_俬逩灬. 提交于 2019-12-02 02:39:18

问题


I am using facebook version 4.14 in my app inorder to share Hashtag along with Imageurl and Contenturl using ShareLinkConent. Now Hashtag is successfully posted inFacbook .

But unfortunately , in Facebook feed, imageurl is replaced by content url metadata. I am attaching the FaceBook feed screenshot here. In that instead of image url i am getting the Content Url metadata image. Please let me know what i am doing wrong here. I am posting my code below

   ShareHashtag shareHashTag = new ShareHashtag.Builder().setHashtag(influencer.hashtag_name).build();
                    if (ShareDialog.canShow(ShareLinkContent.class) && !influencer.influencer_link.toString().equalsIgnoreCase("") && !influencer.influencer_link.toString().equalsIgnoreCase("null")) {
                        ShareLinkContent linkContent = new ShareLinkContent.Builder()
                                .setContentUrl(Uri.parse(influencer.influencer_link))
                                .setImageUrl(Uri.parse("https://d3kvf6cfq06287.cloudfront.net/influencer/image2_1469508676.jpg"))
                                .setShareHashtag(shareHashTag)
                                .setContentDescription(textd)
                                .build();

                        shareDialog.show(linkContent);

Also, I am using gradle depencies for FaceBook

compile 'com.facebook.android:facebook-android-sdk:[4.14.0]'


回答1:


   ShareLinkContent linkContent = new ShareLinkContent.Builder()
                                    .setShareHashtag(shareHashTag)
                                    .setContentDescription(textd)
                                    .setContentUrl(Uri.parse(influencer.influencer_link))
                                    .setImageUrl(Uri.parse(selectedIceCreamImagePath))  //Uri.parse("https://d3kvf6cfq06287.cloudfront.net/influencer/image2_1469508676.jpg"))
                                    .build();

                            shareDialog.show(linkContent, ShareDialog.Mode.FEED);


We need to open the ShareDialog with the Mode.FEED option.. Then our image will be posted correctly in FaceBook Feed


来源:https://stackoverflow.com/questions/39020477/facebook-sharelinkcontent-setimageurl-is-replaced-by-contenturl-metadata-in-andr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!