Share quiz score on Facebook and twitter?


(frank-edouard wozniak) #1

hello !

my client need to post a quiz final score (made with hype of course) on facebook and twitter posts (using sharers).

for the score i use this excellent read : Howto: Simple Quiz Example

the score system is working fine… but how to share the user final score on Facebook and Twitter ?

is it possible to achieve that ?

thank you all

frank


(Olof Pock) #2

if you have the fb api included in HeadHTML you can send a post via this script:

<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : 'xxx', //Your App ID
      xfbml      : true,
      version    : 'v2.5'
    });
  };

  (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>

trigger this script on button click

FB.ui({
  method: 'feed',
  link: 'http://www.sampleURL',
  description:'You answered ' + window.quizScore + ' out of 10 questions correctly',
  picture: 'http://www.sample.com/image/sample.jpg',
  name: 'Name',
}, function(response){});

Best Regards
Olof


(frank-edouard wozniak) #3

thank you very much olof !

by the way now i need a Facebook app iD. no problem if my quiz is made with hype ? do i need to import my quiz in the Facebook app ?

merci beaucoup !


(Olof Pock) #4

You only need the ID and the URL from where you will post.

You setup all of these in fb developer section.


(frank-edouard wozniak) #5

thank you very much Olof !


(frank-edouard wozniak) #6

sorry olof, but how to trigger the script on button click ?

i’ve already got a Facebook share button via iFrame to share the quiz via share_button.php

could you help me with that ?

thank you again…

f e w


(Olof Pock) #7

here is a working example i did last year.
it’s in german and english and a little more complex then the original one

  • shuffled questions
  • english and german texts via initial.js
  • to change the language put ?lang=en or ?lang=de at the end of the .html file
  • first scene only showed on mobile devices

qz_culture16_eng.hype.zip (219.1 KB)


(frank-edouard wozniak) #8

thanks a lot Olof for your example file !! my quiz for mobile is now working perfectly !

for the quiz I created a second screen resolution in hype (for iPad) and I had to deal with the unique ID… so I duplicate everything (functions)… the ‘score’ is now ‘score2’ and it’s working fine… the problem is with the Facebook share : do I need to change something to make the FB share function to work ? because the share page don’t appear :frowning: !

thank you to give me a hint… the deadline is… TODAY !

AAAARGH !

thanks again

f e w


(Olof Pock) #9

Share me a link so I can see what you have


(frank-edouard wozniak) #10

in french