如何通过预览分享Facebook App链接到Facebook?

时间:2017-06-18 16:11:15

标签: android facebook facebook-graph-api facebook-android-sdk

我想在我的应用程序中实现Facebook功能的共享。我的应用程序是仅限Android的应用程序。我想要分享给Facebook的数据是用户生成的文本和图像。所以基本上当其他用户点击“分享”按钮,将打开ShareDialog并将其发布到他们的Facebook帐户。

为了做到这一点,我使用Mobile Hosting Api成功获取应用链接,我将其分享到Facebook,然后点击它,它可以直接到我的应用程序或Play商店。

但现在问题是,我在Facebook上看到的应用程序链接如下所示

appearance in Facebook

我尝试使用.setImageUrl.setContentDescription,但这已被弃用。

然后我阅读this question并尝试实现我的代码,如下所示

Bitmap image = null;
SharePhoto photo = null;

try {
   URL url = new URL(postImageUrl);
   image = BitmapFactory.decodeStream(url.openConnection().getInputStream());
   } catch (MalformedURLException e) {
      e.printStackTrace();
   }
   if (image !=null) {
      photo = new SharePhoto.Builder()
                   .setBitmap(image)
                    .setImageUrl(Uri.parse(postImageUrl))
                    .setUserGenerated(true)
                    .build();
    }

    // Create an object
    ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
          .putString("og:type", "article")
          .putString("og:title", "A Fun Story in Messenglass")
          .putString("og:description", postStatus)
          .build();

     // Create an action
   ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
   .setActionType("news.reads")
   .putObject("article", object)
   .putPhoto("image",photo)
    .build();

   // Create the content
  ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
      .setPreviewPropertyName("article")
      .setAction(action)
      .setContentUrl(Uri.parse(Facebook app link)) //here is the app links
      .build();

     shareDialog.show(getActivity(),content);

通过这个Open Graph故事,我对Facebook的链接共享有预览,但是当我点击链接时,不会将我重定向到我的应用程序,而是将我重定向到Facebook的App中心。

我尝试提交我的应用以供Open Graph故事审核,但我的开发者App Dashboard没有任何Open Graph stories部分。

这是Facebook链接的前景,这很好,但点击时不会引导我到我的应用程序,但引导我到应用程序中心 enter image description here

这是我读过的关于Open Graph Review的文档 https://developers.facebook.com/docs/apps/review/opengraph/

所以我错过了,所以我可以分享我的应用程序链接,从Mobile Hosting Api到Facebook,有一个很棒的预览?请给我一些建议

更新 在我实现上面的代码并在真实设备中测试后,我成功地将用户生成的照片和文本添加到共享对话框中。但是当我在共享对话框中单击“发布”时,它会弹出一个进度对话框“正在发送”然后关闭,没有任何其他错误或其他什么,但我检查Facebook时间表,我没有共享的帖子出现。

以下是我的应用中分享对话框的展望,但没有出现在Facebook时间轴 enter image description here

有人可以告诉我我错过了什么吗?为了分享由Mobile Hosting Api生成的applink,我想做什么,并在Facebook时间轴上显示帖子中的预览照片或说明?

0 个答案:

没有答案
相关问题