public async Task <SendMessageResponse> SendPhoto(Account to, Photo photo) { var payload = new { _uuid = Guid.NewGuid().ToString(), device_id = this.device.Id, _csrftoken = wrapper.GetCookieValue("csrftoken"), client_context = Guid.NewGuid().ToString(), type = "media", recipient_users = $"[[ {to.Id} ]]" }; var response = wrapper .SetResource($"direct_v2/threads/broadcast/upload_photo/ ") .PostAsMultipartWithImage(payload, photo.Content()).Result .Content.ReadAsStringAsync().Result .Deserialize <SendMessageResponse>(); return(response); }
public async Task <UploadResponse> UploadPhoto(Photo photo) { var predictedUploadId = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalMilliseconds; var payload = new { _uuid = Guid.NewGuid().ToString(), device_id = this.device.Id, _csrftoken = wrapper.GetCookieValue("csrftoken"), // client_context = Guid.NewGuid().ToString(), type = "media", image_compression = JsonConvert.SerializeObject(new { lib_name = "jt", lib_version = "1.3.0", quality = "92" }), upload_id = predictedUploadId //recipient_users = $"[[ {to.Id} ]]" }; var response = wrapper .SetResource($"upload/photo/") .PostAsMultipartWithImage(payload, photo.Content()).Result .Content.ReadAsStringAsync().Result .Deserialize <UploadResponse>(); return(response); }