/// <summary> /// /// </summary> /// <param name="responseStrem"></param> /// <returns></returns> public static ClientLogin Parse(Stream Response) { using (StreamReader streamRd = new StreamReader(Response)) { string strResponse = streamRd.ReadToEnd(); ClientLogin newClientLogin = new ClientLogin(); newClientLogin.Auth = strResponse.Substring(5, strResponse.IndexOf("\n") - 5); newClientLogin.YouTubeUser = strResponse.Substring(strResponse.IndexOf("YouTubeUser="******"YouTubeUser=") - 12); return(newClientLogin); } }
/// <summary> /// /// </summary> /// <param name="responseStrem"></param> /// <returns></returns> public static ClientLogin Parse(Stream Response) { using (StreamReader streamRd = new StreamReader(Response)) { string strResponse = streamRd.ReadToEnd(); ClientLogin newClientLogin = new ClientLogin(); newClientLogin.Auth = strResponse.Substring(5, strResponse.IndexOf("\n") - 5); newClientLogin.YouTubeUser = strResponse.Substring(strResponse.IndexOf("YouTubeUser="******"YouTubeUser=") - 12); return newClientLogin; } }
/// <summary> /// /// </summary> /// <param name="Auth"></param> /// <param name="POSTData"></param> /// <returns></returns> public void DoPOST(ClientLogin Auth, MemoryStream POSTDt) { string retVal = string.Empty; this.YouTubeRequest.Method = HTTPMethods.POST.ToString(); this.YouTubeRequest.Headers.Add("Authorization", "GoogleLogin auth=" + Auth.Auth); this.YouTubeRequest.Headers.Add("X-GData-Key", "key=" + Auth.DeveloperKey); this.YouTubeRequest.ContentLength = POSTDt.ToArray().Length; this.POSTData = POSTDt; this.YouTubeRequest.BeginGetRequestStream(ReadCallback, this); }
/// <summary> /// /// </summary> /// <param name="Auth"></param> /// <returns></returns> public void DoGET(ClientLogin Auth) { string retVal = string.Empty; this.YouTubeRequest.Method = HTTPMethods.GET.ToString(); this.YouTubeRequest.Headers.Add("Authorization", "GoogleLogin auth=" + Auth.Auth); this.YouTubeRequest.Headers.Add("X-GData-Key", "key=" + Auth.DeveloperKey); this.YouTubeRequest.BeginGetResponse(ReadCallbackResponse, this); //using (HttpWebResponse response = (HttpWebResponse)this.YouTubeRequest.GetResponse()) //{ // using (StreamReader streamRd = new StreamReader(response.GetResponseStream())) // { // retVal = streamRd.ReadToEnd(); // } //} //return retVal; }
/// <summary> /// /// </summary> /// <param name="UserName"></param> /// <param name="Password"></param> /// <param name="Source"></param> public void Login(string UserName, string Password, string Source) { //Console.WriteLine("Login...."); string strPOSTData = Requests.ClientLoginRequest(UserName, Password, Source); MemoryStream ms = new MemoryStream(); ms.Write(Encoding.UTF8.GetBytes(strPOSTData), 0, Encoding.UTF8.GetByteCount(strPOSTData)); Request.InitURI(URI.ClientLogin); Request.YouTubeRequest.ContentType = YouTubeWebRequest.strContentType; Request.YouTubeRequest.KeepAlive = false; //ClientLogin.Parse(this.AuthInfo, request.DoPOST(this.AuthInfo, ms)); Request.DoPOST(this.AuthInfo, ms); eventWaitResponse.WaitOne(); ClientLogin.Parse(this.AuthInfo, this.strResponse); //Console.WriteLine(this.AuthInfo.YouTubeUser); //Console.WriteLine(this.AuthInfo.Auth); this.bIsAuthorized = true; }
/// <summary> /// /// </summary> /// <param name="Response"></param> /// <returns></returns> public static void Parse(ClientLogin AuthInfo, string Response) { AuthInfo.Auth = Response.Substring(5, Response.IndexOf("\n") - 5); AuthInfo.YouTubeUser = Response.Substring(Response.IndexOf("YouTubeUser="******"YouTubeUser=") - 12); }
/// <summary> /// /// </summary> /// <param name="Response"></param> /// <returns></returns> public static void Parse(ClientLogin AuthInfo,string Response) { AuthInfo.Auth = Response.Substring(5, Response.IndexOf("\n") - 5); AuthInfo.YouTubeUser = Response.Substring(Response.IndexOf("YouTubeUser="******"YouTubeUser=") - 12); }