I’m trying to use the following code so when a person clicks on a picture the dialog box comes up for them to share it on their news feed. When they press share a download box should appear as in ‘save as/cancel’ and so on. If they cancel before sharing it, a message should pop up saying that they need to share to be able to download.
I have got it to come up with the dialog when the image is pressed and everything works but i dont know how to put the rest into the code. I’m guessing it’s to do with the response part at the bottom but i cant figure it out or find something on how to use it anywhere. I have tryed every possible google search I can think off at the moment.
Thanks in advance for any help!
(I don’t have any of my info in the code and I just used the Facebook example for the most part)
<body>
<div id='fb-root'></div>
<script src='http://connect.facebook.net/en_US/all.js'></script>
<p><a onclick='postToFeed(); return false;'><img src="RANDOM IMAGE.png" alt="IMAGE"/></a></p>
<p id='msg'></p>
<script>
FB.init({appId: "1234567890", status: true, cookie: true});
function postToFeed() {
// calling the API ...
var obj = {
method: 'feed',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
name: 'Facebook Dialogs',
caption: 'Reference Documentation',
description: 'Using Dialogs to interact with users.'
};
function callback(response) {
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}`enter code here`
FB.ui(obj, callback);
}
</script>
</body>
You must check response[‘post_id’] in “function callback”. If user really share your picture, facebook send post id. Then you can call javascript function to appear save/cancel.