private string toJson(Message message) { MemoryStream stream = new MemoryStream(); serializer.WriteObject(stream, message); stream.Position = 0; return new StreamReader(stream).ReadToEnd(); }
private Boolean send(Message message) { string base64Output = toBase64(toJson(message)); //System.Diagnostics.Debug.WriteLine(base64Output); WebRequest request = WebRequest.Create("http://api.mixpanel.com/track/?data=" + base64Output); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); response.Close(); return response.StatusCode == HttpStatusCode.OK; }