Hello
@Joris_Demmers ,
Step 1: Paste the following code to the header in the look and feel
<script>
var gid;
function statusChangeCallback(response) {
console.log('statusChangeCallback');
console.log(response);
if (response.status === 'connected') {
getFBData();
} else {
document.getElementById('status').innerHTML = 'Please log ' +
'into this app.';
}
}
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
window.fbAsyncInit = function() {
FB.init({
appId : '875253029346318',
cookie : true, // enable cookies to allow the server to access
// the session
xfbml : true, // parse social plugins on this page
version : 'v2.8' // use graph api version 2.8
});
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
};
(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 = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function getFBData() {
FB.api('/me', function(response) {
fbinfo = new Array();
fbinfo[0] = response.id;
fbinfo[1] = response.first_name;
fbinfo[2] = response.last_name;
fbinfo[3] = response.email;
gid=response.id;
var im = document.getElementById("pic").setAttribute("src", "http://graph.facebook.com/" + response.id + "/picture?type=normal");
});
}
</script>
Step 2: Now if you look at the last line of the code we are addding src attribute to the img tag with id "pic". Hence you must assign id="pic" to your img tag where you are displaying the image(profile picture) in the page.
Step 3: For next pages also you need to have a img tag with id="pic" and paste following code in the js(onReady) option of the question on that page
`var im = document.getElementById("pic").setAttribute("src", "http://graph.facebook.com/" + gid + "/picture?type=normal");`
@Joris_Demmers Let me know if you got the implementation and got that working, because its working for me.
@Sona that works perfectly! Thank you very much!
So thanks to
@Sona displaying the user profile picture anywhere in the survey works absolutely perfect (thanks again for that!).
What I was now wondering in addition is if there would be any way to get the FB first_name, last_name and email (
@Sona's code already takes care of that) and then use that as the default choice text for a text question, so basically autofill the text box with it. Qualtrics' Default Choice boxes do not seem to accept html...
Any advice here would be great and very much appreciated!