So, I'm trying to make Facebook Feed Dialog to work through Their API but had no success on it so far.
I'm using Facebook Javascript SDK to do it, and the FB.ui method.
<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>
This is how my link looks like:
<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>
The error given when I click the share 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."
I ended using another way to use the Feed Dialog.
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>