Exemplo n.º 1
0
        private static UploadedResponse PublishVideo(UploadResponse uploadResponse, string accessToken)
        {
            var request = WebRequest.Create("https://api.dailymotion.com/me/videos?url=" + HttpUtility.UrlEncode(uploadResponse.url));

            request.Method      = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.Headers.Add("Authorization", "OAuth " + accessToken);

            var requestString = String.Format("title={0}&tags={1}&channel={2}&published={3}",
                                              HttpUtility.UrlEncode("some title"),
                                              HttpUtility.UrlEncode("tag1"),
                                              HttpUtility.UrlEncode("news"),
                                              HttpUtility.UrlEncode("true"));

            var requestBytes = Encoding.UTF8.GetBytes(requestString);

            var requestStream = request.GetRequestStream();

            requestStream.Write(requestBytes, 0, requestBytes.Length);

            var response = request.GetResponse();

            var    responseStream = response.GetResponseStream();
            string responseString;

            using (var reader = new StreamReader(responseStream))
            {
                responseString = reader.ReadToEnd();
            }

            var uploadedResponse = JsonConvert.DeserializeObject <UploadedResponse>(responseString);

            return(uploadedResponse);
        }
Exemplo n.º 2
0
        private static UploadedResponse PublishVideo(UploadResponse uploadResponse, string accessToken)
        {
            var request = WebRequest.Create("https://api.dailymotion.com/me/videos?url=" + HttpUtility.UrlEncode(uploadResponse.url));
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.Headers.Add("Authorization", "OAuth " + accessToken);

            var requestString = String.Format("title={0}&tags={1}&channel={2}&published={3}",
                HttpUtility.UrlEncode("some title"),
                HttpUtility.UrlEncode("tag1"),
                HttpUtility.UrlEncode("news"),
                HttpUtility.UrlEncode("true"));

            var requestBytes = Encoding.UTF8.GetBytes(requestString);

            var requestStream = request.GetRequestStream();

            requestStream.Write(requestBytes, 0, requestBytes.Length);

            var response = request.GetResponse();

            var responseStream = response.GetResponseStream();
            string responseString;
            using (var reader = new StreamReader(responseStream))
            {
                responseString = reader.ReadToEnd();
            }

            var uploadedResponse = JsonConvert.DeserializeObject<UploadedResponse>(responseString);
            return uploadedResponse;
        }