Open tonywang1990 opened 6 years ago
I used a Flask server running with endpoints that would initiate OAuth sequences for Twitter and Instagram. I certified it as https to avoid CORS issues. In Qualtrics, I made a survey item with a link to this endpoint, and I embedded callback Javascript in that item. The Next button stayed hidden until the credentials sharing had been confirmed by a signal from my Flask server.
The Javascript looked like this:
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place Your Javascript Below This Line*/
$('NextButton') && $('NextButton').hide();
var source = "${e://Field/referral}"
var target = "${e://Field/study_username}"
var follower;
if (source=="twitter") {
follower = "${e://Field/username}";
} else if (source=="mturk") {
follower = "${q://QID54/ChoiceTextEntryValue}"
}
var unique_id = "${e://Field/unique_id}"
var medium = "Instagram"
$j('#'+medium+'-verifier').click(function() {
$j('#'+medium+'-validate-verify').text("Verifying username, please wait.");
$j.ajax({
type: "GET",
url: "https://research.andrewgarrettreece.com/verify2/"+medium+"/"+follower,
dataType: "jsonp",
jsonpCallback: 'callback',
success: function(data) {
if (data.verified == true) {
$j('#'+medium+'-validate-verify').text("Username verified! Continuing with survey...");
$j('#NextButton').click()
} else {
$j('#'+medium+'-validate-verify').text("Username not verified. Please try again.");
}
}
});
});
});
Can you provide some general guidlines on how to link this python code with qualtrics to allow respondents to log in and grant permission?