我网站的 Facebook 签到按钮
Facebook Check-In button for my website
我正在尝试为我的网站实现一个 "Check-In" 按钮。主要目的:当用户点击该按钮时,将打开一个 Facebook 共享对话框,并在自定义位置检查用户。用户 post 不会自动 posted 并且消息不会被设置为不违反 Facebook 政策。
据我所知,Facebook Open Graph 故事可能会发生这种情况。我添加了一个 "Place" 选项作为开放图对象类型。我知道要做到这一点,我的应用程序需要 "publish_actions" 权限,并且我的应用程序处于开发人员模式,所以这不是问题所在。我使用 Facebook Javascript SDK。所以代码是这样的:
这是 OG 标记(由 facebook 提供):
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# place: http://ogp.me/ns/place#">
<meta property="fb:app_id" content="my-app-id" />
<meta property="og:type" content="place" />
<meta property="og:url" content="my-url" />
<meta property="og:title" content="my-place-name" />
<meta property="og:image" content="sample-url-image" />
<meta property="place:location:latitude" content="Sample Location: Latitude" />
<meta property="place:location:longitude" content="Sample Location: Longitude" />
这是调用共享对话框的函数(也由 facebook 提供):
function share()
{
FB.api(
'me/objects/place',
'post',
{'object': {
'og:url': 'my-url',
'og:title': 'my-place-name',
'og:type': 'place',
'og:image': 'sample-url-image',
'og:description': '',
'fb:app_id': 'my-app-id',
'place:location:latitude': 'Sample Location: Latitude',
'place:location:longitude': 'Sample Location: Longitude'
}},
function(response) {
// handle the response
// for example (using Jquery)
$('#element').append('shared');
}
);
}
函数的调用方式如下:
<span onclick="share()">click to share</span>
<div id="element"></div>
问题是代码不起作用,共享对话框无法打开。我的错误在哪里?
最后我将它创建为共享按钮。可以选择检查它是否真的发布了,之后没有取消。
FB.ui({
method: 'share',
mobile_iframe: true,
title: 'My title',
href: 'url to share',
picture: 'image URL',
description: 'The description'
}, function (response) {
if (response && !response.error_message) {
alert('Thank you for sharing!');
} else {
alert('You have cancelled the share.');
}
});
},{scope: 'email'});
我正在尝试为我的网站实现一个 "Check-In" 按钮。主要目的:当用户点击该按钮时,将打开一个 Facebook 共享对话框,并在自定义位置检查用户。用户 post 不会自动 posted 并且消息不会被设置为不违反 Facebook 政策。 据我所知,Facebook Open Graph 故事可能会发生这种情况。我添加了一个 "Place" 选项作为开放图对象类型。我知道要做到这一点,我的应用程序需要 "publish_actions" 权限,并且我的应用程序处于开发人员模式,所以这不是问题所在。我使用 Facebook Javascript SDK。所以代码是这样的:
这是 OG 标记(由 facebook 提供):
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# place: http://ogp.me/ns/place#">
<meta property="fb:app_id" content="my-app-id" />
<meta property="og:type" content="place" />
<meta property="og:url" content="my-url" />
<meta property="og:title" content="my-place-name" />
<meta property="og:image" content="sample-url-image" />
<meta property="place:location:latitude" content="Sample Location: Latitude" />
<meta property="place:location:longitude" content="Sample Location: Longitude" />
这是调用共享对话框的函数(也由 facebook 提供):
function share()
{
FB.api(
'me/objects/place',
'post',
{'object': {
'og:url': 'my-url',
'og:title': 'my-place-name',
'og:type': 'place',
'og:image': 'sample-url-image',
'og:description': '',
'fb:app_id': 'my-app-id',
'place:location:latitude': 'Sample Location: Latitude',
'place:location:longitude': 'Sample Location: Longitude'
}},
function(response) {
// handle the response
// for example (using Jquery)
$('#element').append('shared');
}
);
}
函数的调用方式如下:
<span onclick="share()">click to share</span>
<div id="element"></div>
问题是代码不起作用,共享对话框无法打开。我的错误在哪里?
最后我将它创建为共享按钮。可以选择检查它是否真的发布了,之后没有取消。
FB.ui({
method: 'share',
mobile_iframe: true,
title: 'My title',
href: 'url to share',
picture: 'image URL',
description: 'The description'
}, function (response) {
if (response && !response.error_message) {
alert('Thank you for sharing!');
} else {
alert('You have cancelled the share.');
}
});
},{scope: 'email'});