I need to post the image using the image url in my facebook app is that possible? How to post image to Facebook on button click? I have stored imageUrl in variable image and the facebook URL in the variable shareUrl,
following is the complete facebook URL :
"https://www.facebook.com/dialog/feed?app_id=843228839026054&caption=example.com&display=popup&redirect_uri="+encodeURIComponent("http://www.facebook.com/")+"&name=%title%&description=%desc%&picture=%image%".
<html>
<head>
<script>
var doShare = function(title, description)
{
if(title && description)
{
image="http://www.sxc.hu/assets/182945/1829445627/small-flowers-1019552-m.jpg";
/* for readability i store the url like this, above this code u can find
the complete facebook url. */
shareUrl = "https://www.facebook.com/dialog/feed?";
shareUrl += "app_id=843228839026054&caption=example.com&display=popup&";
shareUrl += "redirect_uri="+encodeURIComponent("http://www.facebook.com/");
shareUrl += "&name=%title%&description=%desc%&picture=%image%";
var url = shareUrl.replace(/%title%/g, encodeURIComponent(title));
url = url.replace(/%desc%/g, encodeURIComponent(description));
url = url.replace(/%image%/g, encodeURIComponent(image));
var isOpen = window.open(url);
if(!isOpen)
{
console.log('Please turn off "Block pop up" setting to proceed further.');
}
}
};
</script>
</head>
<body>
<div id='share'>
<input type='button' onclick ='doShare("TITLE","DESCRIPTION")'>Share</input>
</div>
</body>
</html>
FB.ui({
method: 'feed',
name: "some name",
link: "somelink.com",
picture: urltobeshared,
caption: 'some caption',
description: "some descrtiption",
},
function(response) {
if (response && response.post_id) {
console.log('Thank you');
}
}
);
},
docs are here.Hope that helps