Beispiel #1
0
        public RobloxResponse sendTrade(TradeResponseType type, String tradeJSON, String XRSFToken, String tradeID, String cookies)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.roblox.com/Trade/TradeHandler.ashx");

            request.KeepAlive = true;
            request.Accept    = "application/json, text/javascript, */*; q=0.01";
            request.Headers.Add("Origin", @"http://www.roblox.com");
            request.Headers.Add("X-CSRF-TOKEN", XRSFToken);
            request.Headers.Add("X-Requested-With", @"XMLHttpRequest");
            request.UserAgent   = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36";
            request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
            request.Referer     = "http://www.roblox.com/Trade/TradeWindow.aspx?TradePartnerID=85503967";
            request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
            request.Headers.Set(HttpRequestHeader.AcceptLanguage, "en-US,en;q=0.8");
            request.Headers.Set(HttpRequestHeader.Pragma, "no-cache");
            request.Headers.Set(HttpRequestHeader.CacheControl, "no-cache");
            request.Headers.Set(HttpRequestHeader.Cookie, cookies);
            request.Method = "POST";
            request.ServicePoint.Expect100Continue = false;
            String body = "";

            if (type == TradeResponseType.Accept)
            {
                body = "TradeID=" + tradeID + "&cmd=maketrade&TradeJSON=" + tradeJSON;
            }
            else if (type == TradeResponseType.Decline)
            {
                body = "TradeID=" + tradeID + "&cmd=decline";
            }
            else if (type == TradeResponseType.Send)
            {
                body = "cmd=send&TradeJSON=" + tradeJSON;
            }
            byte[] postBytes = System.Text.Encoding.UTF8.GetBytes(body);
            request.ContentLength = postBytes.Length;
            Stream stream = request.GetRequestStream();

            stream.Write(postBytes, 0, postBytes.Length);
            stream.Close();

            HttpWebResponse response       = (HttpWebResponse)request.GetResponse();
            Stream          responseStream = RobloxUtils.decodeStream(response);

            using (StreamReader readStream = new StreamReader(responseStream, Encoding.UTF8))
            {
                RobloxResponse robloxResponse = JsonConvert.DeserializeObject <RobloxResponse>(readStream.ReadToEnd());
                robloxResponse.data = (TradeResponseInfo)robloxResponse.data;
                return(robloxResponse);
            }
        }
Beispiel #2
0
        public RobloxResponse sendTrade(TradeResponseType type, String tradeJSON, String XRSFToken, String tradeID, String cookies)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.roblox.com/Trade/TradeHandler.ashx");
            request.KeepAlive = true;
            request.Accept = "application/json, text/javascript, */*; q=0.01";
            request.Headers.Add("Origin", @"http://www.roblox.com");
            request.Headers.Add("X-CSRF-TOKEN", XRSFToken);
            request.Headers.Add("X-Requested-With", @"XMLHttpRequest");
            request.UserAgent = RobloxUtils.UserAgent;
            request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
            request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
            request.Headers.Set(HttpRequestHeader.AcceptLanguage, "en-US,en;q=0.8");
            request.Headers.Set(HttpRequestHeader.Pragma, "no-cache");
            request.Headers.Set(HttpRequestHeader.CacheControl, "no-cache");
            request.Headers.Set(HttpRequestHeader.Cookie, cookies);
            request.Method = "POST";
            request.ServicePoint.Expect100Continue = false;
            String body = "";
            if (type == TradeResponseType.Accept)
            {
                body = "TradeID=" + tradeID + "&cmd=maketrade&TradeJSON=" + tradeJSON;
            }
            else if (type == TradeResponseType.Decline)
            {
                body = "TradeID=" + tradeID + "&cmd=decline";
            }
            else if (type == TradeResponseType.Send)
            {
                body = "cmd=send&TradeJSON=" + tradeJSON;
            }
            byte[] postBytes = Encoding.UTF8.GetBytes(body);
            request.ContentLength = postBytes.Length;
            Stream stream = request.GetRequestStream();
            stream.Write(postBytes, 0, postBytes.Length);
            stream.Close();

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream responseStream = RobloxUtils.decodeStream(response);
            using (StreamReader readStream = new StreamReader(responseStream, Encoding.UTF8))
            {
                RobloxResponse robloxResponse = JsonConvert.DeserializeObject<RobloxResponse>(readStream.ReadToEnd());
                if (robloxResponse.data is TradeResponseInfo)
                {
                    robloxResponse.data = (TradeResponseInfo)robloxResponse.data;
                }
                return robloxResponse;
            }
        }