I'm trying to make client side application to get tracks from soundcloud according to docs
I've added <script src='http://connect.soundcloud.com/sdk.js'></script>
to <head>
of my site. And added following code as docs says to my js.
//I've replaced YOUR_CLIENT_ID with my client id I got when registered my app and http://example.com/callback with my callback.html also I've filled redirect uri field with it.
SC.initialize({
client_id: 'YOUR_CLIENT_ID',
redirect_uri: 'http://example.com/callback'
});
// initiate auth popup
SC.connect(function() {
SC.get('/me', function(me) {
alert('Hello, ' + me.username);
});
});
Also I've created callback.html
<html lang="en">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Connect with SoundCloud</title>
</head>
<body onload="window.opener.setTimeout(window.opener.SC.connectCallback, 1)">
<b style="width: 100%; text-align: center;">This popup should automatically close in a few seconds</b>
</body>
</html>
Now I get popup window where I can enter my email and password and when I enter it, I got message: This popup should automatically close in a few seconds. But it's not closing. In console I got message:
Uncaught SecurityError: Blocked a frame with origin "http://sscopin.temp.swtest.ru" from accessing a frame with origin "swappedout://". The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "swappedout". Protocols must match
Also I don't see any alert, so I suppose that it's not connected.Also console.log
of SC shows me SC object.
Solutions? Suggestions?
Read more docs. Here I've found, that it's not necessary to use rederict_uri at all. Only client_id. Also here I've found how to get tracks uploaded by people. So, it's quite simple. To play tracks from user we should:
1. Initialize object with our client_id obtained after registration of application.
To get track id we should:
Username is in settings>profile>profile url of soundcloud. Tracks is an list of objects where there is an id property that we can use next
3. To add playing of track on click