【发布时间】:2017-09-26 06:08:27
【问题描述】:
我正在尝试使用 Express.js 和 AngularJS 设置与 SPA 的社交共享。 事情是,我想分享动态内容,所以我使用angular-facebook-factory 来获取 Facebook 按钮。按钮工作,参数设置,只是我传递的图像、标题和描述参数永远不会到达 Facebook 共享弹出屏幕。
$scope.shareEvent = function (event) {
console.log('verify values: ', event.image); // works fine!
FacebookService.share({
href: 'http://www.example.com/event/'+event_id+'/', // this value is passed
title: event.title, // Not shown
description: event.desc, // Not shown
image: event.image // Not shown
}, function (response) {
$scope.me = response;
$scope.status = true;
})
}
FB 共享从http://www.example.com/ 加载默认值(如和)并使用set href 参数(http://www.example.com/event)。我也尝试了 method: 'feed' ,但没有成功。 我应该在页面上有几个不同的分享按钮,所以我猜 meta og 标签不会这样做......
这是具有 ui-view 数量的 SPA,使用 html5 的 ui-router 工作正常,一切正常。
【问题讨论】:
-
Facebook 正在消除在运行时指定这些值的所有可能性,请参阅developers.facebook.com/docs/apps/… 在请求 URL 时让服务器返回 OG 元数据是唯一可行的方法之后。
-
所以这肯定意味着我必须使用服务器端缓存才能正确响应?
-
是的。如果您不想最终实现所有功能,那么 prerender.io 之类的服务可以提供帮助。
标签: angularjs html facebook express