Exemplo n.º 1
0
        public string RejectAComment(string refreshtoken, string commmentId)
        {
            oAuthTokenYoutube objoAuthTokenYoutube = new oAuthTokenYoutube(_clientId, _clientSecret, _redirectUrl);
            oAuthToken        objoauth             = new oAuthToken(_clientId, _clientSecret, _redirectUrl);
            string            accesstoken_jdata    = objoauth.GetAccessToken(refreshtoken);
            JObject           JData       = JObject.Parse(accesstoken_jdata);
            string            accesstoken = JData["access_token"].ToString();
            string            RequestUrl  = "https://www.googleapis.com/youtube/v3/comments/setModerationStatus?id=" + commmentId + "&moderationStatus=rejected&key=" + accesstoken + "&alt=json";
            string            postdata    = "";
            Uri path = new Uri(RequestUrl);

            string[] header   = { "Authorization", "X-JavaScript-User-Agent" };
            string[] val      = { "Bearer " + accesstoken, "Google APIs Explorer" };
            string   response = string.Empty;

            try
            {
                response = objoAuthTokenYoutube.Post_WebRequest(Socioboard.GoogleLib.Authentication.oAuthToken.Method.POST, RequestUrl, postdata, header, val);
            }
            catch (Exception Err)
            {
                Console.Write(Err.StackTrace);
            }
            return(response);
        }
Exemplo n.º 2
0
        public string replyToComment(string refreshtoken, string parentid, string commentText)
        {
            oAuthTokenYoutube objoAuthTokenYoutube = new oAuthTokenYoutube(_clientId, _clientSecret, _redirectUrl);
            oAuthToken        objoauth             = new oAuthToken(_clientId, _clientSecret, _redirectUrl);

            string  accesstoken_jdata = objoauth.GetAccessToken(refreshtoken);
            JObject JData             = JObject.Parse(accesstoken_jdata);
            string  accesstoken       = JData["access_token"].ToString();

            commentText = commentText.Replace("\\n", "######2525").Replace("\\", "\\\\").Replace("\"", "\\\"").Replace("######2525", "\\n");;

            string RequestUrl = "https://www.googleapis.com/youtube/v3/comments?part=snippet&key=" + accesstoken + "&alt=json";

            string postdata = "{\"snippet\":{\"parentId\":\"" + parentid + "\",\"textOriginal\":\"" + commentText + "\"}}";

            Uri path = new Uri(RequestUrl);

            string[] header   = { "Authorization", "X-JavaScript-User-Agent" };
            string[] val      = { "Bearer " + accesstoken, "Google APIs Explorer" };
            string   response = string.Empty;


            try
            {
                response = objoAuthTokenYoutube.Post_WebRequest(Socioboard.GoogleLib.Authentication.oAuthToken.Method.POST, RequestUrl, postdata, header, val);
            }
            catch (Exception Err)
            {
                Console.Write(Err.StackTrace);
            }



            return(response);
        }
Exemplo n.º 3
0
        public string Post_Comments_toVideo(string refreshtoken, string VideoId, string commentText)
        {
            oAuthTokenYoutube objoAuthTokenYoutube = new oAuthTokenYoutube(_clientId, _clientSecret, _redirectUrl);


            oAuthToken objoauth = new oAuthToken(_clientId, _clientSecret, _redirectUrl);

            string  accesstoken_jdata = objoauth.GetAccessToken(refreshtoken);
            JObject JData             = JObject.Parse(accesstoken_jdata);
            string  accesstoken       = JData["access_token"].ToString();


            string RequestUrl = "https://content.googleapis.com/youtube/v3/commentThreads?part=snippet&key=" + accesstoken + "&alt=json";

            string postdata = "{\"snippet\": {\"videoId\": \"" + VideoId + "\",\"topLevelComment\": {\"snippet\": {\"textOriginal\": \"" + commentText + "\"}}}}";

            Uri path = new Uri(RequestUrl);

            string[] header   = { "Authorization", "X-JavaScript-User-Agent", "Origin", "X-Origin" };
            string[] val      = { "Bearer " + accesstoken, "Google APIs Explorer", "https://content.googleapis.com", "https://developers.google.com" };
            string   response = string.Empty;


            try
            {
                response = objoAuthTokenYoutube.Post_WebRequest(Socioboard.GoogleLib.Authentication.oAuthToken.Method.POST, RequestUrl, postdata, header, val);
            }
            catch (Exception Err)
            {
                Console.Write(Err.StackTrace);
            }



            return(response);
        }