I'm creating a mobile application which plays music stored in my SoundCloud account.
开发者_高级运维Is there any way to create an automatic login to my SoundCloud account (PHP)? I don't want each user to have to use OAuth because it is only accessing my account and they will have already logged into my site.
Basically i just want to have a list of users tracks, and have the users be able to add or delete tracks from this account with my web form.
All the documentation I've seen uses OAuth to log into individuals accounts but i only want to access my account.
any help or a direction to look would be great
thanks
I was able to login in to a soundcloud account programmatically in PHP using the undocumented (in PHP as yet!) credentialsFlow function:
$sc_client_id = "Client ID from the developer page on soundcloud for your app";
$sc_secret = "Client Secret from the developer page";
$sc_user = "your soundcloud account user";
$sc_pass = "your soundcloud account password";
// create client object and set access token
$client = new Services_Soundcloud($sc_client_id, $sc_secret);
// login
$client->credentialsFlow($sc_user, $sc_pass);
Then you can upload audio files using the $client variable, e.g. this code, taken from 'Uploading Audio Files', http://developers.soundcloud.com/docs#uploading
// upload audio file
$track = json_decode($client->post('tracks', array(
'track[title]' => 'This is my sound',
'track[asset_data]' => '@/absolute/path/to/file.mp3'
)));
// print track link
print $track->permalink_url;
Here's my suggestion: have your users create individual SoundCloud accounts for themselves, then create an interface that allows them to share individual tracks with you, which you can then aggregate into a playlist of some sort (which could then be streamed to whatever device you wish, via SoundCloud).
This has the following advantages:
- You maintain control of your own personal SoundCloud account and don't have to worry about it expanding to an unmanageable size.
- You have the ability to moderate tracks, allowing you to screen for copyrighted or troll content.
- It's more extensible -- if you use something like Drupal's aggregate facility, or a plugin like FeedWordPress (not sure what your CMS platform is, if any), the RSS feeds of tracks you're using can also be taken and used elsewhere by your users, thus potentially increasing the size of your audience. I.e., a widget that displays the latest tracks people can drop onto social profiles or blogs or whatever.
- If set up well enough, your solution might be able to encompass non-SoundCloud streaming sources -- YouTube, etc.
Basically, you're dumping links sent to you into an RSS feed, which are super easy to work with both cross-browser and cross-OS. I'd personally use Drupal for this, but I'm sure there are ways to do this just as easily in Joomla!, WordPress or any other CMS worth its salt.
Looks like you can parse the track data in JSON format
http://api.soundcloud.com/tracks?client_id=#{client_id}&limit=10&format=json
There's no "login" either. You're just grabbing a user's public tracks.
Soundcloud has a whole developer API that you should probably brush up on.
精彩评论