Facebook
From Alonzo, 1 Month ago, written in JavaScript.
Embed
Download Paste or View Raw
Hits: 147
  1. // Replace 'YOUR_CLIENT_ID' with your actual SoundCloud API client ID
  2. const clientId = 'YOUR_CLIENT_ID';
  3.  
  4. // Fetch the user's playlists
  5. function fetchPlaylists(userId) {
  6.   const url = `https://api.soundcloud.com/users/${userId}/playlists?client_id=${clientId}&limit=25`;
  7.  
  8.   $.ajax({
  9.     url: url,
  10.     method: 'GET',
  11.     dataType: 'json',
  12.     success: function(data) {
  13.       displayPlaylists(data);
  14.     },
  15.     error: function(error) {
  16.       console.error('Error fetching playlists:', error);
  17.     }
  18.   });
  19. }
  20.  
  21. // Display the playlist titles
  22. function displayPlaylists(playlists) {
  23.   const playlistTitles = playlists.map(playlist => playlist.title);
  24.   alert(playlistTitles.join('\n'));
  25. }
  26.  
  27. // Replace 'USER_ID' with the actual user ID you want to fetch playlists for
  28. const userId = 'USER_ID';
  29. fetchPlaylists(userId);