Ejemplo n.º 1
0
        private async Task <string> UploadImage(string status)
        {
            const string url       = "https://upload.twitter.com/1.1/media/upload.json";
            var          generator = new CommandGenerator();

            generator.Generate(status);

            var base64Image = generator.DrawToBase64();
            var requestData = new SortedDictionary <string, string> {
                { "media_data", base64Image }
            };

            Authenticate(url, requestData);

            var content = new FormUrlEncodedContent(requestData);

            var response = await _client.PostAsync(url, content);

            var responseData = await response.Content.ReadAsStringAsync();

            var responseDataJson = (JObject)JsonConvert.DeserializeObject(responseData);

            return(responseDataJson.Value <string>("media_id_string"));
        }