Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Share quiz results on Facebook

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.

like image 800
tanya Avatar asked Apr 01 '15 11:04

tanya


People also ask

Can you post a quiz on Facebook?

A Facebook quiz is the perfect way to entertain your followers while receiving valuable feedback. In this blog post, you will learn how to publish a quiz on your Facebook Page. You can also take a look at the 1-minute tutorial video above for more information. Start by opening the Quizzes for Pages app in a new tab.

Can you put quiz on Facebook story?

Step 1: Once you've taken or imported a photo or video in Stories, tap “Stickers” in the top-right corner of the screen. Step 2: Tap the Question sticker. Step 3: Type the question you want to ask. Note: You can also tap the suggestion buttons to have Facebook fill in a template question for you.

What happens when you answer quizzes on Facebook?

These kinds of questions will get you to click on them for curiosity, but it can actually be dangerous to click on those links! Readers Digest confirmed Facebook quizzes may lead you to a website with dangerous downloads, or have malicious links and possible viruses included in the questions.


1 Answers

You can use facebook js SDK for this. you can call FB.ui method feed to achieve this. Create a button on your page

<input type="button" onclick="postToFeed()" value="Share" />

.Use the below function javscript to share on facebook.

function postToFeed() {
    // calling the API ...
    var obj = {
      method: 'feed',
      link: 'https://www.azeezkallayi.com/',
      description: "description goes here",
      picture: 'https://www.azeezkallayi.com/demo/test/womens-day.jpg',
      name: 'International womens day'       
    };
     FB.ui(obj);
   }

Here you can change the values of parameters as you want.

like image 75
Azeez Kallayi Avatar answered Oct 17 '22 11:10

Azeez Kallayi