通过Facebook的墙壁分享一个简单的图像。
或者,如果某天图像离线:
API错误代码:191
API错误说明:指定的URL不属于应用程序
错误消息:redirect_uri不归应用程序所有。
我的问题是:我做错了什么?
首先,我加载Facebook的JavaScript SDK:
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId: 'xxx',
channelUrl: '//localhost/channel.html',
status: true,
xfbml: true
});
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {
return;
}
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
其次,我的应用程序上有以下按钮:
<a href="#" onClick="publishOnFacebook()">
<i class="icons icon-facebook-big"></i></a>
publishOnFacebook()
方法是:
function publishOnFacebook() {
FB.ui(
{
method: 'feed',
name: 'Facebook Dialogs',
link: 'https://developers.facebook.com/docs/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple,
consistent interface for applications to
interface with users.'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
}
最后,这是我的应用程序:
答案 0 :(得分:2)
尝试以下内容。
<script type="text/javascript">
function publishOnFacebook() {
FB.ui(
{
method: 'feed',
name: 'Facebook Dialogs',
link: 'http://localhost/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
}
</script>
<a href="#" onClick="publishOnFacebook()">
<i class="icons icon-facebook-big"></i></a>