Description
Here i explain how to share image with text on facebook from my website using api. Using below example you can post image with specific link and caption and also post description as you like.
First of all you need to get your facebook App-Id using facebook developer account. After create facebook app, you have appId provided in API.
Use this appId in following javascript function and enter your image url in picture property and also you can define your caption and description text in related properties following below:
Note: That image url should be live. Because facebook can't display local path or url. That's why your website or image url should be live.
Here i explain how to share image with text on facebook from my website using api. Using below example you can post image with specific link and caption and also post description as you like.
First of all you need to get your facebook App-Id using facebook developer account. After create facebook app, you have appId provided in API.
Use this appId in following javascript function and enter your image url in picture property and also you can define your caption and description text in related properties following below:
Note: That image url should be live. Because facebook can't display local path or url. That's why your website or image url should be live.
<script type="text/javascript">
function ShareOnFacebook() {
FB.init({
appId: "your app_id", scope: 'publish_actions',
status: true, cookie: true });
FB.ui(
{
method: 'share',
name: 'Facebook Dialogs',
href: window.location.href,
link: 'https://developers.facebook.com/docs/dialogs/',
picture: 'your picture url',
caption: 'your caption text',
description: 'your description text'
},
function (response) {
if (response == response.post_id) {
alert('Post was published');
} else {
alert('Post was not published');
}
}
);
}
</script>
This post very useful for me.
ReplyDeleteThank you
Very short and easy to use example. It's really good one for developer. Thanks
ReplyDelete