private string GetUploadKey(string action, string tpid, string tpk)
        {
            Dictionary <string, string> args = new Dictionary <string, string>();

            args.Add("action", action);
            args.Add("tpid", tpid);
            args.Add("sig", ZAppHelper.GetMD5(action + tpid + tpk));
            args.Add("responsetype", "XML");

            string response = SendGetRequest(URLAPI, args);

            if (!string.IsNullOrEmpty(response) && CheckResponse(response))
            {
                string upk = ZAppHelper.GetXMLValue(response, "uploadkey");

                if (string.IsNullOrEmpty(upk))
                {
                    Errors.Add("Upload key is empty.");
                }

                return(upk);
            }

            Errors.Add("Unable to get upload key.");

            return(null);
        }
        public override UploadResult Upload(Stream stream, string fileName)
        {
            UploadResult ur = new UploadResult();

            string action = "getuploadkey", tpid = TinyPicID, tpk = TinyPicKey;
            string upk = GetUploadKey(action, tpid, tpk);

            if (!string.IsNullOrEmpty(upk))
            {
                Dictionary <string, string> arguments = new Dictionary <string, string>();

                if (AccountType == AccountType.User && !string.IsNullOrEmpty(Shuk))
                {
                    action = "userupload";
                    arguments.Add("shuk", Shuk);
                }
                else
                {
                    action = "upload";
                }

                arguments.Add("action", action);
                arguments.Add("tpid", tpid);
                arguments.Add("sig", ZAppHelper.GetMD5(action + tpid + tpk));
                arguments.Add("responsetype", "XML");
                arguments.Add("upk", upk);
                arguments.Add("type", "image");
                arguments.Add("tags", string.Empty);

                ur.Source = UploadData(stream, URLAPI, fileName, "uploadfile", arguments);

                if (!string.IsNullOrEmpty(ur.Source) && CheckResponse(ur.Source))
                {
                    ur.URL          = ZAppHelper.GetXMLValue(ur.Source, "fullsize");
                    ur.ThumbnailURL = ZAppHelper.GetXMLValue(ur.Source, "thumbnail");
                }
            }

            return(ur);
        }
        public override UploadResult Upload(Stream stream, string fileName)
        {
            UploadResult ur = new UploadResult();

            Dictionary <string, string> arguments = new Dictionary <string, string>();

            arguments.Add("key", DeveloperKey);
            arguments.Add("public", IsPublic ? "yes" : "no");

            if (AccountType == AccountType.User && !string.IsNullOrEmpty(RegistrationCode))
            {
                arguments.Add("cookie", RegistrationCode);
            }

            ur.Source = UploadData(stream, "http://www.imageshack.us/upload_api.php", fileName, "fileupload", arguments);

            if (!string.IsNullOrEmpty(ur.Source))
            {
                ur.URL          = ZAppHelper.GetXMLValue(ur.Source, "image_link");
                ur.ThumbnailURL = ZAppHelper.GetXMLValue(ur.Source, "thumb_link");
            }

            return(ur);
        }
        public string UserAuth(string email, string password)
        {
            string action = "userauth", tpid = TinyPicID, tpk = TinyPicKey;

            Dictionary <string, string> args = new Dictionary <string, string>()
            {
                { "action", action },
                { "tpid", tpid },
                { "sig", ZAppHelper.GetMD5(action + tpid + tpk) },
                { "email", email },
                { "pass", password }
            };

            string response = SendPostRequest(URLAPI, args);

            if (!string.IsNullOrEmpty(response))
            {
                string result = ZAppHelper.GetXMLValue(response, "shuk");

                return(HttpUtility.HtmlEncode(result));
            }

            return(string.Empty);
        }