protected KnetikRequest CreateRequest(string path, string body = "[]", string method = "post", int timestamp = -1, string serviceBundle = null, bool isForm = false) { if (timestamp == -1) { TimeSpan t = (DateTime.UtcNow - new DateTime (1970, 1, 1)); timestamp = (int)t.TotalSeconds; } string url = BuildUrl (path, serviceBundle); System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding(); byte[] data = encoding.GetBytes(body); KnetikRequest req = new KnetikRequest (method, url, data); if (isForm) { req.SetHeader("Content-type", "application/x-www-form-urlencoded"); } else { req.SetHeader("Content-type", "application/json"); req.SetHeader("Accept", "application/json"); } req.SetHeader("User-Agent", "Knetik Unity SDK"); if (AccessToken != null && AccessToken != "") { req.SetHeader("Authorization", "Bearer " + AccessToken); } return req; }
protected KnetikRequest CreateRequest(string path, string body = "[]", string method = "post", int timestamp = -1, string serviceBundle = null) { if (timestamp == -1) { TimeSpan t = (DateTime.UtcNow - new DateTime (1970, 1, 1)); timestamp = (int)t.TotalSeconds; } string url = BuildUrl (path, serviceBundle); string signature = BuildSignature (body, timestamp); string envelope = BuildEnvelope (body, timestamp, signature); Log ("URL: " + url); Log ("Envelope:\n" + envelope); System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding(); byte[] data = encoding.GetBytes(envelope); KnetikRequest req = new KnetikRequest (method, url, data); req.SetHeader("Content-type", "application/json"); req.SetHeader("User-Agent", "Knetik Unity SDK"); return req; }