Facebook 提要对话框错误 191
Facebook Feed Dialog error 191
所以,我正在尝试让 Facebook Feed Dialog 通过他们的 API 工作,但到目前为止没有成功。
我正在使用 Facebook Javascript SDK 和 FB.ui 方法。
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'MY FB APP ID',
xfbml : true,
version : 'v2.3'
});
};
(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 fbShare(url, title, descr, image) {
FB.ui({
method: 'feed',
name: title,
link: url,
caption: 'Title',
description: descr,
picture: image,
display: 'popup',
redirect_uri: url
},
function(response) {
if (response && response.post_id) {
//alert('Post was published.');
} else {
//alert('Post was not published.');
}
});
}
</script>
这是我的 link 的样子:
<a href="javascript:fbShare('http://mywebsite.com/avaliacao/9d8ee3cb3ad759b134da94802e7c49c8', 'My Site Has a new share', 'Lorem ipsum is a pseudo-Latin text used in web design, typography, layout, and printing in place of English to emphasise design elements over content.', 'http://mywebsite.com.br/img/fb-share.png')">Share</a>
点击分享报错link:
An error occurred. Please try again later.
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."
删除 redirect_url
并重试。或确保在应用程序设置中将 redirect_url
的域添加为网站平台 (http://mywebsite.com/)。
我结束了使用另一种方式来使用 Feed 对话框。
Javascript:
<script type="text/javascript">
function fbShare(url, title, descr, image, winWidth, winHeight) {
var winTop = (screen.height / 2) - (winHeight / 2);
var winLeft = (screen.width / 2) - (winWidth / 2);
window.open('https://www.facebook.com/dialog/feed?app_id=APP-ID
&name=' + title
+ '&picture=' + image
+ '&caption=My+Caption
&display=popup' + '
&description=' + descr + '
&link=' + url + '
&redirect_uri=http://mywebsite.com.br/fb-close-popup-window',
'sharer',
'top=' + winTop + ',
left=' + winLeft + ',
toolbar=0,
status=0,
width=' + winWidth + ',
height=' + winHeight);
}
</script>
HTML
<a href="javascript:fbShare('http://mywebsite.com/9d8ee3cb3ad759b134da94802e7c49c8','My Site Has a new share','Lorem ipsum is a pseudo-Latin text used in web design, typography, layout, and printing in place of English to emphasise design elements over content.','http://mywebsite.com.br/img/fb-share.png',520, 350)">Share</a>
所以,我正在尝试让 Facebook Feed Dialog 通过他们的 API 工作,但到目前为止没有成功。
我正在使用 Facebook Javascript SDK 和 FB.ui 方法。
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'MY FB APP ID',
xfbml : true,
version : 'v2.3'
});
};
(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 fbShare(url, title, descr, image) {
FB.ui({
method: 'feed',
name: title,
link: url,
caption: 'Title',
description: descr,
picture: image,
display: 'popup',
redirect_uri: url
},
function(response) {
if (response && response.post_id) {
//alert('Post was published.');
} else {
//alert('Post was not published.');
}
});
}
</script>
这是我的 link 的样子:
<a href="javascript:fbShare('http://mywebsite.com/avaliacao/9d8ee3cb3ad759b134da94802e7c49c8', 'My Site Has a new share', 'Lorem ipsum is a pseudo-Latin text used in web design, typography, layout, and printing in place of English to emphasise design elements over content.', 'http://mywebsite.com.br/img/fb-share.png')">Share</a>
点击分享报错link:
An error occurred. Please try again later.
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."
删除 redirect_url
并重试。或确保在应用程序设置中将 redirect_url
的域添加为网站平台 (http://mywebsite.com/)。
我结束了使用另一种方式来使用 Feed 对话框。
Javascript:
<script type="text/javascript">
function fbShare(url, title, descr, image, winWidth, winHeight) {
var winTop = (screen.height / 2) - (winHeight / 2);
var winLeft = (screen.width / 2) - (winWidth / 2);
window.open('https://www.facebook.com/dialog/feed?app_id=APP-ID
&name=' + title
+ '&picture=' + image
+ '&caption=My+Caption
&display=popup' + '
&description=' + descr + '
&link=' + url + '
&redirect_uri=http://mywebsite.com.br/fb-close-popup-window',
'sharer',
'top=' + winTop + ',
left=' + winLeft + ',
toolbar=0,
status=0,
width=' + winWidth + ',
height=' + winHeight);
}
</script>
HTML
<a href="javascript:fbShare('http://mywebsite.com/9d8ee3cb3ad759b134da94802e7c49c8','My Site Has a new share','Lorem ipsum is a pseudo-Latin text used in web design, typography, layout, and printing in place of English to emphasise design elements over content.','http://mywebsite.com.br/img/fb-share.png',520, 350)">Share</a>