This project is read-only.
1
Vote

current wrapper does not work with version 1.8.4 and above

description

I am in the process of building an app around your API wrapper, but have found that on uTorrent 2.2, it fails on each request.
 
The official uTorrent website talks about the new Token Authentication System. (http://www.utorrent.com/developers/webapi#devs4). the Token Auth Documentation (http://trac.utorrent.com/trac/wiki/TokenSystem) explains how to get an auth token (see code below) but the problem is that the API does not take this token.
 
        string tokenURL = string.Format("http://{0}:{1}/gui/token.html", address.Text, port.Text);
 
        string tokenHTML = getURL(tokenURL, userName.Text, password.Text);
 
        Regex regex = new Regex("\\<[^\\>]*\\>");
 
        string token = regex.Replace(tokenHTML, string.Empty);
 
aux code:
 
    private string getURL(string url, string username, string password)
    {
        HttpWebRequest Request = (HttpWebRequest)WebRequest.Create(url);
        //Request.Method = "GET";
        Request.Credentials = new NetworkCredential(username,password);
        //Request.PreAuthenticate = true;
        HttpWebResponse Response = (HttpWebResponse)Request.GetResponse();
 
        return StreamToString(Response.GetResponseStream());
    }
 
    private string StreamToString(System.IO.Stream readStream)
    {
        string result = null;
        string tempstring = null;
        int count = 0;
        byte[] buffer = new byte[8192];
        do
        {
            count = readStream.Read(buffer, 0, buffer.Length);
            if (count != 0)
            {
                tempstring = System.Text.Encoding.ASCII.GetString(buffer, 0, count);
                result = result + tempstring;
            }
        }
        while (count > 0);
        readStream.Close();
        return result;
    }

comments

tiernano wrote Jan 22, 2011 at 10:24 PM

A patch has been uploaded ([patch: 8172]) which i have used as a work around for this issue.

wrote Feb 14, 2013 at 1:51 AM