如何使用示例

时间:2015-06-05 04:18:43

标签: android facebook facebook-graph-api

是否有可能从我的Android应用程序在Facebook上发布此帖子的功能作为App Link?如果有人使用Facebook应用程序点击这篇文章,它将被引导到G.P.安装我的应用程序,如果它已安装,它将打开我的应用程序,有足够的数据在我的应用程序活动中查看此帖子?

到目前为止,我找不到一个示例来说明如何创建App Link对象,以及如何在此对象中包含数据以便稍后从intent中检索 - >额外的,我完全混淆了如何在Android中实现它。

例如,在我的应用程序中,我想在Facebook上的帖子中分享http://youtube.com/xxxxx链接,如何使用Facebook App Link主机功能创建App Link?

编辑1:

我需要了解有关应用程序链接的内容,是否会为每个帖子创建应用程序链接,以便从我的应用程序发布,或创建应用程序链接一次以表示我的应用程序?

编辑2:

如何让我的应用名称以蓝色作为Instagram并点击它打开我的应用程序或转到我的Google Play进行安装(如果没有安装)

How to get my app name to be in Blue as Instagram and clicking on it opens my application or go to my

编辑3:

这是我用来分享的代码,但我没有将我的应用程序名称视为Instagram中的“可点击蓝色链接”,如图所示:

    ShareDialog shareDialog = new ShareDialog(mMainActivity);

    if (ShareDialog.canShow(ShareLinkContent.class))
    {
        ShareLinkContent linkContent;
        if(aURL == null)
        {
            linkContent = new ShareLinkContent.Builder().build();
        }
        else
        {
            linkContent = new ShareLinkContent.Builder()
                    .setContentUrl(Uri.parse(aURL))
                    .build();
        }

        shareDialog.show(linkContent);
    }

我应该在Facebook信息中心的应用设置页面中进行具体更改吗?

3 个答案:

答案 0 :(得分:2)

您应该使用开放图表操作。首先你应该创建一个对象。然后添加一个动作类型。然后需要创建一个故事。 &安培;你必须提交审查过程你的Facebook应用程序。通常共享代码看起来像这样。阅读文档https://developers.facebook.com/docs/sharing/opengraph/android。 &安培;您需要使用应用链接 - https://developers.facebook.com/docs/applinks/android

// Create an object
ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
    .putString("og:type", "books.book")
    .putString("og:title", "A Game of Thrones")
    .putString("og:description", "In the frozen wastes to the north of Winterfell, sinister and supernatural forces are mustering.")
    .putString("books:isbn", "0-553-57340-3")
    .build();

// Create an action
ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
    .setActionType("books.reads")
    .putObject("book", object)
    .build();

// Create the content
ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
    .setPreviewPropertyName("book")
    .setAction(action)
    .build();

ShareDialog.show(activityOrFragment, content);

答案 1 :(得分:0)

如果我理解你的问题,你想从你的应用发布到Facebook(一个URL)。 你能做的是:

Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, your_link_here );  
startActivity(Intent.createChooser(intent, "Share via"));

这将打开一个应用列表,您可以在其中共享您的链接,其中包括Facebook应用程序(如果已安装)。还可以看看facebook的TOS。您不能预先填写邮件,因为它违反了他们的政策。如果您想与网址共享一些文字,则必须使用Facebook的SDK。

答案 2 :(得分:0)

我尝试过同样的事情。事实证明,您的应用应该出现在应用中心(Facebook)上。然后它才会变成蓝色链接。

在我的情况下,我尝试点击该链接,但它登陆了一个页面,上面写着:

  

配置错误的应用抱歉,"我的应用"还没有获准在中国展出   App Center。

所以我得到了这个提示。