Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var credentials = {
- client_id : '',
- client_secret : '',
- username : '',
- password : ''
- };
- var jsonfile = require('jsonfile')
- SC = require('soundcloud-nodejs-api-wrapper');
- var sc = new SC(credentials);
- // this client object will be explained more later on
- var client = sc.client();
- client.exchange_token(function(err, result) {
- var access_token = arguments[3].access_token;
- console.log('Full API auth response was:');
- console.log(arguments);
- // we need to create a new client object which will use the access token now
- var clientnew = sc.client({access_token : access_token});
- // Get Users Profile comments
- clientnew.get('/users/14859705/comments', {limit : 10000000}, function(err, result) {
- if (err) console.error(err); // check for an error
- var file = './users/14859705-profile-comments.json' // create a profile comments json file
- var obj = result; // set the results to be placed into created json file
- jsonfile.writeFileSync(file, obj, {spaces: 2}) // Write the file to disk with json Spacing of 2
- });
- // Get list of users Tracks
- clientnew.get('/users/14859705/tracks', {limit : 10000000}, function(err, result) {
- if (err) console.error(err); // check for an error
- var file = './users/14859705-tracks.json' // create a profile comments json file
- var obj = result; // set the results to be placed into created json file
- jsonfile.writeFileSync(file, obj, {spaces: 2}) // Write the file to disk with json Spacing of 2
- });
- // Get Comments from all Tracks found (Temp Hard Coded In)
- clientnew.get('/tracks/251259713/comments', {limit : 10000000}, function(err, result) {
- if (err) console.error(err); // check for an error
- var file = './tracks/251259713-comments.json' // create a profile comments json file
- var obj = result; // set the results to be placed into created json file
- jsonfile.writeFileSync(file, obj, {spaces: 2}) // Write the file to disk with json Spacing of 2
- });
- clientnew.get('/tracks/237179318/comments', {limit : 10000000}, function(err, result) {
- if (err) console.error(err); // check for an error
- var file = './tracks/237179318-comments.json' // create a profile comments json file
- var obj = result; // set the results to be placed into created json file
- jsonfile.writeFileSync(file, obj, {spaces: 2}) // Write the file to disk with json Spacing of 2
- });
- clientnew.get('/tracks/251259740/comments', {limit : 10000000}, function(err, result) {
- if (err) console.error(err); // check for an error
- var file = './tracks/251259740-comments.json' // create a profile comments json file
- var obj = result; // set the results to be placed into created json file
- jsonfile.writeFileSync(file, obj, {spaces: 2}) // Write the file to disk with json Spacing of 2
- });
- clientnew.get('/tracks/218685053/comments', {limit : 10000000}, function(err, result) {
- if (err) console.error(err); // check for an error
- var file = './tracks/218685053-comments.json' // create a profile comments json file
- var obj = result; // set the results to be placed into created json file
- jsonfile.writeFileSync(file, obj, {spaces: 2}) // Write the file to disk with json Spacing of 2
- });
- // EXAMPLE OF POSTING TO :: lets try to create a new empty playlist
- //var jsonString = '{"playlist":{"title":"JommysList"}}';
- //clientnew.post('/playlists', jsonString, function(err, result) {
- // if (err) console.error(err);
- // console.log(result); // should show the json object of our new playlist
- //});
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement