我正在使用下面的代码打开Facebook页面URL的Facebook共享对话框.
问题是,当我通过Facebook应用程序查看我墙上的共享帖子时,我发现没有共享页面封面的帖子.
如果我通过我的墙上的Facebook应用程序共享同一页面,我会找到带有共享页面封面的帖子(当然这更酷).
下面的代码中是否缺少参数?
我正在使用Facebook SDK 4.1.2
- FacebookDialog shareDialog = new ShareDialog(mMainActivity);
- if (ShareDialog.canShow(ShareLinkContent.class))
- {
- ShareLinkContent linkContent = new ShareLinkContent.Builder()
- .setContentUrl(Uri.parse(aFacebookPageURL))
- .build();
- shareDialog.show(linkContent);
- }
编辑1:
使用.setImageUrl(Uri.parse(aPageCoverURL))
您可以看到上半部分(通过Facebook移动应用程序共享)和下半部分(通过我的应用程序共享)之间的差异.
编辑2:如何使用以下代码共享Facebook页面?下面的代码不起作用,没有出现共享对话框,我不知道是否有缺少参数或者此代码不是为了共享页面,但我正在尝试.
- ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
- .putString("og:type","page")
- .putString("og:title",aTitle)
- .putString("og:url",aURL)
- .build();
- // Create an action
- ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
- .setActionType(null)
- .putObject("page",object)
- .build();
- ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
- .setPreviewPropertyName("page")
- .setAction(action)
- .build();
- ShareDialog.show(mMainActivity,content);
解决方法
来自Facebook
documentation:
Links
When people share links from your app to Facebook,it includes
attributes that show up in the post:
- a contentURL,the link to be shared
- a contentTitle that represents the title of the content in the link
- a imageURL,the URL of thumbnail image that will appear on the post
- a contentDescription of the content,usually 2-4 sentences
- ShareLinkContent linkContent = new ShareLinkContent.Builder()
- .setContentUrl(Uri.parse(aFacebookPageURL))
- .setImageUrl(Uri.parse(imageUrl))
- .build();
这是SDK的一个分享:
这是一个直接来自应用程序的共享: