Surveymonkey allows you to access all your surveys and associated features like collectors, users, groups, etc via their RESTful API. Before accessing the API you need to make sure followings -
- Create an app in SurveyMonkey
- Get access token
- Call API endpoint via your favorite code library
Following is an example of Node JS code using https -
var https = require('https'); var accessToken='YourAccessToken' var options = { hostname: 'api.surveymonkey.com', path: '/v3/surveys', method: 'GET', port: '443', headers: { 'Content-Type' : 'application/json', 'Authorization' : 'Bearer ' + accessToken } }; var body = ''; var req = https.request(options, (res) => { //console.log('Response is '+res.statusCode); res.on('data', function (chunk) { body += chunk; }); res.on('end', function () { console.log(body); callback(null,body); }); }); req.on('error', (e) => { console.error("There is some error "+e); callback(e); }); req.end();
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.