Esempio n. 1
0
        /// <summary>
        /// Attempts to login with the given username and password.
        /// </summary>
        /// <returns>A FollwitAPI object if login is successful.</returns>
        public static FollwitApi Login(string username, string hashedPassword, string apiUrl)
        {
            if (apiUrl == null) apiUrl = DefaultUrl;

            IFollwitProxy proxy = CreateProxy(username, hashedPassword, apiUrl);
            try { object result = proxy.CheckAuthentication(); }
            catch (XmlRpcServerException ex) {
                if (ex.Message == "Unauthorized") return null;
                else throw;
            }

            FollwitApi api = new FollwitApi(username, hashedPassword, apiUrl, proxy);
            api.GetUserData();

            proxy.RequestEvent += new XmlRpcRequestEventHandler(api.proxy_RequestEvent);
            proxy.ResponseEvent += new XmlRpcResponseEventHandler(api.proxy_ResponseEvent);

            return api;
        }