Man*_*uel 12 facebook facebook-sharer facebook-graph-api facebook-javascript-sdk facebook-apps
我正在研究一个测验脚本.因此,我想分享测验的结果,而不是og元数据.
我知道可以使用旧的FB.ui feed动作添加自定义名称,标题,描述和消息,而不是共享URL.例如:
FB.ui({
method: 'feed',
href: url,
name: name,
caption: title,
description: des,
message: message,
picture: img,
}, function(response){});
Run Code Online (Sandbox Code Playgroud)
但是我想这会很快被弃用?!
这也可能与新的份额api一起使用吗?或者我可以用自定义故事来做这件事吗?怎么样?我正在寻找类似的东西
FB.ui({
method: 'share',
href: url,
name: name,
caption: title,
description: des,
message: message,
picture: img,
}, function(response){});
Run Code Online (Sandbox Code Playgroud)
但这不起作用:/它只需要href.其他一切都被忽略,而不是预先填写:(
有没有最好的做法或Facebook推荐的方法来做到这一点?
API文档:https://developers.facebook.com/docs/sharing/reference/share-dialog
谢谢.我非常感谢你的帮助
Dam*_*irR 10
更新于27.06.2018.
旧版本的代码停止正常工作.共享图像在左侧显示为小图像,而不是大型全列图像.修复是替换action_type: 'og.shares'为action_type: 'og.likes'.
使用此代码:
FB.ui({
method: 'share_open_graph',
action_type: 'og.likes',
action_properties: JSON.stringify({
object: {
'og:url': url,
'og:title': title,
'og:description': des,
'og:image': img
}
})
},
function (response) {
// Action after response
});
Run Code Online (Sandbox Code Playgroud)
这适用于API版本2.9+.请注意,og.shares action_type不再建议使用,因为FB文档中未提及它并且未正确显示大图像.我现在用og.likes.小的缺点是在共享对话框顶部附近的"John Doe喜欢运行中的对象"这样的句子,并在用户墙上共享内容.
完整的工作示例结帐使用JavaScript动态更改Facebook开放图元数据.
我不知道在Share对话框中记录了这些参数的位置,但我有一个猜测,这些都可以工作.作为提示,请将Feed方法中使用的"name"参数更改为"title".我是从一个网页上的多个共享按钮自定义共享.显然,用你自己的变量或'string'替换所有'custom ...'变量:
FB.ui({
method: 'share',
href: 'http://yourwebpage.com',
picture: customImage,
title: customTitle,
description: customDescription,
caption: customCaption
}, function(response) {});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
23496 次 |
| 最近记录: |