如何共享来自Android的标题和描述使用Facebook SDK 4.1.2至Facebook [英] How to share Title and description from android to facebook using facebook sdk 4.1.2

查看:893
本文介绍了如何共享来自Android的标题和描述使用Facebook SDK 4.1.2至Facebook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Facebook的SDK 4.1.2内容共享到Facebook。
https://developers.facebook.com/docs/sharing/android
这是我下文称这样做的任务,是在Facebook上分享一个链接的内容全成的链接。

  shareDialog =新ShareDialog(ShareActivity.this);
              ShareLinkContent linkContent =新ShareLinkContent.Builder()
                .setContentTitle(你好脸谱)
                .setContentDescription(
                        在'你好Facebook的样品展示简单Facebook的整合)
                .setContentUrl(Uri.parse(http://ramees.com/Uplo​​ads/VideoGallery/17_VG/1_Video_Gallery.mp4))
                。建立();
            shareDialog.show(linkContent);

我已经使用了上述code张贴在Facebook上的链接内容,它是工作successfully.But我没有找到任何code发布标题和描述不作任何链接的内容或图像。任何人都可以帮知道我怎么能做到这一点与Facebook SDK 4.1.2本身。


解决方案

  shareDialog =新ShareDialog(ShareActivity.this);
            ShareOpenGraphObject对象=新ShareOpenGraphObject.Builder()
                    .putString(OG:类型,books.book)
                    .putString(OG:称号,权力的游戏)
                    .putString(OG:描述,在冻结废物冬北,邪恶和超自然力量都卯足。)
                    。.putString(书:ISBN,0-553-57340-3)建设();            ShareOpenGraphAction行动=新ShareOpenGraphAction.Builder()
                    .setActionType(books.reads)。putObject(书,对象)
                    。建立();
            ShareOpenGraphContent内容=新ShareOpenGraphContent.Builder()
            .SET previewPropertyName(书)
            .setAction(动作)
            。建立();
            shareDialog.show(内容);        }

I am using Facebook sdk 4.1.2 to share contents to Facebook . https://developers.facebook.com/docs/sharing/android This is the link i reffered for doing this task And was successfull in sharing a link content in facebook.

shareDialog = new ShareDialog(ShareActivity.this);
              ShareLinkContent linkContent = new ShareLinkContent.Builder()
                .setContentTitle("Hello Facebook")
                .setContentDescription(
                        "The 'Hello Facebook' sample  showcases simple Facebook integration")
                .setContentUrl(Uri.parse("http://ramees.com/Uploads/VideoGallery/17_VG/1_Video_Gallery.mp4"))
                .build();
            shareDialog.show(linkContent);

I have used the above code to post a link content in facebook and it is working successfully.But i didn't find any code to post title and description only without any link content or image. Can anyone help to know how can i do this with Facebook sdk 4.1.2 itself.

解决方案

shareDialog = new ShareDialog(ShareActivity.this);
            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();

            ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
                    .setActionType("books.reads").putObject("book", object)
                    .build();
            ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
            .setPreviewPropertyName("book")
            .setAction(action)
            .build();
            shareDialog.show(content);

        }

这篇关于如何共享来自Android的标题和描述使用Facebook SDK 4.1.2至Facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆