我的脚本代码如下:
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '878892922141778',
xfbml : true,
version : 'v2.1'
});
};
(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/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<script type="text/javascript">
function publishOnFacebook() {
FB.ui(
{
method: 'feed',
name: 'Facebook Dialogs',
link: 'https://apps.facebook.com/878892922141778',
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 hre="#" onclick="publishOnFacebook();" data-share="fb"><span class="fb-icon"></span></a>
但是当我点击分享按钮时,它给了我错误:
API Error Code: 191 API Error Description: The specified URL is not owned by the application Error Message: redirect_uri is not owned by the application.
可能是什么错误?
我的应用详情是:
当我添加:
<a href="javascript:void(o);"
onclick="window.open('https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(location.href),'facebook-share-dialog', 'width=626,height=436');
return false;">
SHARE
</a>
它共享整页。但我只是想分享特定的图像。
请帮帮我。
答案 0 :(得分:1)
如果你想分享图片,那么你可以在FB.ui方法中使用该代码
picture: 'https://apps.facebook.com/test.png' // your image path
我希望这对你有所帮助。