views:

241

answers:

3

How can I log to premium rapidshare account from my source? I tryed this but it is not working:

string authInfo = "name" + ":" + "pass";
authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
client.Headers["Authorization"] = "Basic " + authInfo;

client.DownloadFile("url", "C:\\Temp\\aaaa.file");

OR

WebClient client = new WebClient();

client.Credentials = new NetworkCredential("name", "pass");

client.DownloadFile("url", "C:\\Temp\\aaaa.file");

Is there any simple way how download the file directly from rapidshare premium?

+3  A: 

Use Fiddler to see what is being sent. Then reconstruct the query.

A download manager's logs may also provide some tips.

leppie
Thanx for tip. I will try it!
Simon
+2  A: 

Simple rapidshare class allows you to perform your task without re-inventing the wheel...Otherwise check the APIs from rapidshare.

weismat
I tried this class but it don't work:( I checked the APIs but I did not found any note about direct downloading from premium account.
Simon
+2  A: 

There is my solution. work like a charm:

private void downloadFileAsync(string fileUrl)
        {
            string uriString;

            uriString = "https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi";

            NameValueCollection postvals = new NameValueCollection();
            postvals.Add("login", "aaa");
            postvals.Add("password", "bbb");
            postvals.Add("uselandingpage", "1");

            WebClient myWebClient = new WebClient();

            Byte[] responseArray = myWebClient.UploadValues(uriString, "POST", postvals);

            StreamReader strRdr = new StreamReader(new MemoryStream(responseArray));

            string cookiestr = myWebClient.ResponseHeaders.Get("Set-Cookie");

            myWebClient.Headers.Add("Cookie", cookiestr);
            myWebClient.DownloadFileCompleted += new AsyncCompletedEventHandler(myClient_DownloadFileCompleted);
            myWebClient.DownloadFileAsync(new Uri(fileUrl),"C:\\Temp\\"+Path.GetFileName(fileUrl));
        }
Simon