Solution:
First you need to create the app , after creating you need to write the following code in the page you need to share
<body>
<script>
window.fbAsyncInit = function() {
//SDK loaded, initialize it
FB.init({
appId : 'your-appid',
xfbml : true,
version : 'v2.5'
});
};
//load the JavaScript SDK
(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>
<!-- Your code here -->
</body>
Note: It is better if you place facebook connect code inside the
<body>
tag as i did
<p>
<a rel="nofollow" target="_blank" class=" facebook ">Share</a>
</p>
jQuery(document).ready(function($) {
jQuery('.facebook').click(
function(){
FB.ui(
{
method: 'share',
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.'
},//For checking the response you can use
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
)
});
}
);
then you need to make this app live ,for this go to your developer account on facebook (https://developers.facebook.com/) .select your app -> go to App Review -> then make yes in
Do you want to make this app and all its live features available to the general public?.
Note : Don’t forgot to give email in settings->contact email