【问题标题】:facebook shareDialog when app is\isn't installed - weird behavior?未安装应用程序时的 facebook shareDialog - 奇怪的行为?
【发布时间】:2017-04-19 11:20:38
【问题描述】:

我正在使用 Facebook 的 ShareDialog,以便在我的应用程序中的 Facebook 上共享 printScreen 图像。

安装 Facebook 应用后,它可以正常工作。

当 Facebook 应用未安装时,它不起作用。我看到“加载”屏幕,然后它消失了,没有任何反应。 分享对话框对象到达带有 FacebookException 的 onError 回调:

{FacebookGraphResponseException: (#200) Requires extended permission: publish_actions httpResponseCode: 403, facebookErrorCode: 200, facebookErrorType: OAuthException, message: (#200) Requires extended permission: publish_actions}

那么我真的需要“publish_actions”权限仅用于 facebook 网络而不是 facebook 应用程序吗?奇怪..

Facebook writes:

https://developers.facebook.com/docs/sharing/android

"If the Facebook app is not installed it will automatically fallback to the web-based dialog"

"Now the SDK automatically checks for the native Facebook app. If it isn't installed, the SDK switches people to their default browser and opens the Feed Dialog."

我的代码:

mShareDialog = new ShareDialog(mActivity);

    mShareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
        @Override
        public void onSuccess(Sharer.Result result) {}

        @Override
        public void onCancel() {}

        @Override
        public void onError(FacebookException error) {
            if (error != null) {
                showDialog("facebook app isn't installed");
            }
        }
    });

    if (ShareDialog.canShow(ShareLinkContent.class)) {

        // get a screenshot
        Bitmap image = getScreenshot();

        SharePhoto photo = new SharePhoto.Builder()
                .setBitmap(image)
                .setCaption(getResources().getString(R.string.shareBodyText))
                .build();

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

        mShareDialog.show(content);
    }

那么为什么在没有“publish_actions”的情况下安装 facebook 应用程序时它可以工作,而在没有安装 facebook 应用程序时它不能工作?

【问题讨论】:

    标签: android facebook-graph-api facebook-sharer facebook-share publish-actions


    【解决方案1】:

    这是 SharePhotoContent 的要求,您必须安装本机 Facebook 应用才能分享照片。

    来自Facebook Docs

    照片

    人们可以使用分享功能将您应用中的照片分享到 Facebook 对话框或带有自定义界面。

    • 照片大小必须小于 12MB
    • 人们需要安装原生 Facebook for Android 应用,版本 7.0 或更高版本

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-04-08
      • 2011-06-15
      • 1970-01-01
      • 1970-01-01
      • 2011-11-22
      • 2013-05-31
      • 1970-01-01
      相关资源
      最近更新 更多