Skip to content

Instantly share code, notes, and snippets.

@kyleva
Last active April 15, 2021 16:56
Show Gist options
  • Select an option

  • Save kyleva/c2edf4a57b57e0671d6b387222392120 to your computer and use it in GitHub Desktop.

Select an option

Save kyleva/c2edf4a57b57e0671d6b387222392120 to your computer and use it in GitHub Desktop.

My ID: 9829193

Jacob's Song ID: 994537984

const appVersion = 1618476442;
const appLocale = 'en';
const authToken = ''
const clientId = '';

const likeSongEndpointTemplate = [
  'https://api-v2.soundcloud.com',
  '/users/{{userId}}/track_likes/{{trackId}}',
  '?client_id={{clientId}}&app_version=1618476442&app_locale=en'
].join('');

const currentlySignedInUserId = 9829193;
const djMilamTrackId = 994537984;

const endpoint = likeSongEndpointTemplate
  .replace('{{userId}}', currentlySignedInUserId)
  .replace('{{trackId}}', djMilamTrackId)
  .replace('{{clientId}}', clientId);

fetch(endpoint, {
  data: {
    'app_locale': appLocale,
    'app_version': appVersion,
    clientId
  },
  headers: {
    'Authorization': `OAuth ${authToken}`,
    'Content-Type': 'application/json'
  },
  method: 'PUT',
})
.then(res => res.json())
.then(res => console.log({ res }))
.catch(err => console.error({ err }));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment