Question

How can i determine Auth token (oauth_token), Track Title (track[title]), The file (track[asset_data]) values correctly in code below.

using Krystalware.UploadHelper;
...

System.Net.ServicePointManager.Expect100Continue = false;
var request = WebRequest.Create("https://api.soundcloud.com/tracks") as HttpWebRequest;
//some default headers
request.Accept = "*/*";
request.Headers.Add("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.3");
request.Headers.Add("Accept-Encoding", "gzip,deflate,sdch");
request.Headers.Add("Accept-Language", "en-US,en;q=0.8,ru;q=0.6");

//file array
var files = new UploadFile[] { 
    new UploadFile(Server.MapPath("Downloads//0.mp3"), "track[asset_data]", "application/octet-stream") 
};
//other form data
var form = new NameValueCollection();
form.Add("track[title]", "Some title");
form.Add("track[sharing]", "private");
form.Add("oauth_token", this.Token);
form.Add("format", "json");

form.Add("Filename", "0.mp3");
form.Add("Upload", "Submit Query");
try
{
    using (var response = HttpUploadHelper.Upload(request, files, form))
    {
        using (var reader = new StreamReader(response.GetResponseStream()))
        {
            lblInfo.Text = reader.ReadToEnd();
        }
    }
}
catch (Exception ex)
{
    lblInfo.Text = ex.ToString();
}

how to learn this values to upload an mp3 to my soundcloud account.

Was it helpful?

Solution

If I am understanding your question correctly you want to know what to fill in for Auth token (oauth_token), Track Title (track[title]), The file (track[asset_data]) correct?

oauth_token is a private token you get from soundcloud. You will have to sign up for there developer program to obtain one of these:
http://www.developers.soundcloud.com

once you have one you will replace

this.Token

with they key you obtain.


the track title is simply the title you want to name your track. in

form.Add("track[title]", "Some title");

simply replace "Some title" with your own title.
for asset data, you want to change "Downloads//0.mp3" to the path of the file you want to upload.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top