在没有应用程序的情况下在 Facebook 上分享照片

Posted

技术标签:

【中文标题】在没有应用程序的情况下在 Facebook 上分享照片【英文标题】:Share photo on facebook without app 【发布时间】:2015-06-24 08:59:03 【问题描述】:

如果没有安装 facebook 应用程序,我正在尝试将用户重定向到浏览器以共享我的应用程序中的照片。

我正在使用:

        SharePhoto photo = new SharePhoto.Builder()
                .setImageUrl(Uri.fromFile(new File(path))
                .build();

        final SharePhotoContent content = new SharePhotoContent.Builder()
                .addPhoto(photo)
                .build();

        if (ShareDialog.canShow(SharePhotoContent.class)) 
           //Sharing via facebook app
            shareDialog.show(content);
         else 
           //Sharing via browser
           Intent shareCaptionIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/userxxxx"));
           shareCaptionIntent.setType("image/*");

           //set photo
           shareCaptionIntent.setData(Uri.fromFile(new File(path)));
           shareCaptionIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(path)));

           context.startActivity(Intent.createChooser(shareCaptionIntent, "Share image using"));
        

但是直到现在都没有任何成功。有没有办法分享重定向到 facebook 浏览器页面的内容?

【问题讨论】:

我认为浏览器不会获得额外的数据。 【参考方案1】:

我也遇到过同样的麻烦,我可以说在 facebook 的SharePhotoContent API 中存在一些问题。你可以使用ShareLinkContent分享图片。

ShareLinkContent linkContent = new ShareLinkContent.Builder()
                .setImageUrl("Your url")
                .build();
shareDialog.show(linkContent);

【讨论】:

以上是关于在没有应用程序的情况下在 Facebook 上分享照片的主要内容,如果未能解决你的问题,请参考以下文章