I have spent hours researching this but it seems to be tricky for many developers out there. I have a small php quiz, outputting results from a form in the following way:
if (maxA) {
echo '
<img src="imgs/result4.jpg"/>
<div class="results2">
<p class="title">You are a Bean</p>
<p class="details">Description</p>
</div>';
}
The question is, how to add a Share button at the bottom of this, which will share the result on Facebook, together with the description and the picture. Note that there are four available results.
I have made a public app, and inserted the following in the head:
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '1382290368762081',
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>
And the HTML is yet to be figured out. I went back and forth with this answer: Using "share_open_graph" Facebook UI to create dynamic share dialog for quiz results - but did not actually achieve anything.I think it would be helpful to the whole community, if someone knows the exact way to make this happen, and to share them with us.