Android-Facebook:如何使用ShareOpenGraphContent分享Youtube视频

时间:2016-03-19 20:08:04

标签: android facebook facebook-graph-api youtube

如何使用开放式graph share dialog在Facebook上分享Youtube视频。

这就是我一直在尝试的,它会创建一个帖子,但它不会把我带到youtube。

            String actionName = "play";
            String objectName = "song";
            String nameSpace = "myNameSpace";
            String videoUrl = "https://youtubeUrl";
            String objectType = "music.song";

            ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
                    .putString("og:type", objectType)
                    .putString("og:image", imageUrl)
                    .putString("og:video:url", videoUrl)
                    .putString("og:title", item.getSnippet().getTitle())
                    .build();

            ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
                    .setActionType(nameSpace + ":" + actionName)
                    .putObject(objectName, object)
                    .build();

            ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
                    .setPreviewPropertyName(objectName)
                    .setAction(action)
                    .setContentUrl(Uri.parse(videoUrl))
                    .build();

            ShareDialog.show(context, content);

0 个答案:

没有答案