Advertisement
ronkrtdev

Untitled

Apr 2nd, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. var credentials = {
  2. client_id : '',
  3. client_secret : '',
  4. username : '',
  5. password : ''
  6. };
  7. var jsonfile = require('jsonfile')
  8.  
  9. SC = require('soundcloud-nodejs-api-wrapper');
  10. var sc = new SC(credentials);
  11.  
  12. // this client object will be explained more later on
  13. var client = sc.client();
  14.  
  15. client.exchange_token(function(err, result) {
  16.  
  17. var access_token = arguments[3].access_token;
  18.  
  19. console.log('Full API auth response was:');
  20. console.log(arguments);
  21.  
  22. // we need to create a new client object which will use the access token now
  23. var clientnew = sc.client({access_token : access_token});
  24.  
  25. // Get Users Profile comments
  26. clientnew.get('/users/14859705/comments', {limit : 10000000}, function(err, result) {
  27. if (err) console.error(err); // check for an error
  28. var file = './users/14859705-profile-comments.json' // create a profile comments json file
  29. var obj = result; // set the results to be placed into created json file
  30. jsonfile.writeFileSync(file, obj, {spaces: 2}) // Write the file to disk with json Spacing of 2
  31. });
  32.  
  33. // Get list of users Tracks
  34. clientnew.get('/users/14859705/tracks', {limit : 10000000}, function(err, result) {
  35. if (err) console.error(err); // check for an error
  36. var file = './users/14859705-tracks.json' // create a profile comments json file
  37. var obj = result; // set the results to be placed into created json file
  38. jsonfile.writeFileSync(file, obj, {spaces: 2}) // Write the file to disk with json Spacing of 2
  39. });
  40.  
  41. // Get Comments from all Tracks found (Temp Hard Coded In)
  42. clientnew.get('/tracks/251259713/comments', {limit : 10000000}, function(err, result) {
  43. if (err) console.error(err); // check for an error
  44. var file = './tracks/251259713-comments.json' // create a profile comments json file
  45. var obj = result; // set the results to be placed into created json file
  46. jsonfile.writeFileSync(file, obj, {spaces: 2}) // Write the file to disk with json Spacing of 2
  47. });
  48.  
  49. clientnew.get('/tracks/237179318/comments', {limit : 10000000}, function(err, result) {
  50. if (err) console.error(err); // check for an error
  51. var file = './tracks/237179318-comments.json' // create a profile comments json file
  52. var obj = result; // set the results to be placed into created json file
  53. jsonfile.writeFileSync(file, obj, {spaces: 2}) // Write the file to disk with json Spacing of 2
  54. });
  55.  
  56. clientnew.get('/tracks/251259740/comments', {limit : 10000000}, function(err, result) {
  57. if (err) console.error(err); // check for an error
  58. var file = './tracks/251259740-comments.json' // create a profile comments json file
  59. var obj = result; // set the results to be placed into created json file
  60. jsonfile.writeFileSync(file, obj, {spaces: 2}) // Write the file to disk with json Spacing of 2
  61. });
  62.  
  63. clientnew.get('/tracks/218685053/comments', {limit : 10000000}, function(err, result) {
  64. if (err) console.error(err); // check for an error
  65. var file = './tracks/218685053-comments.json' // create a profile comments json file
  66. var obj = result; // set the results to be placed into created json file
  67. jsonfile.writeFileSync(file, obj, {spaces: 2}) // Write the file to disk with json Spacing of 2
  68. });
  69.  
  70. // EXAMPLE OF POSTING TO :: lets try to create a new empty playlist
  71. //var jsonString = '{"playlist":{"title":"JommysList"}}';
  72. //clientnew.post('/playlists', jsonString, function(err, result) {
  73. // if (err) console.error(err);
  74. // console.log(result); // should show the json object of our new playlist
  75. //});
  76.  
  77. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement