private void GetGameDetailsSource(string gameId, Common.Login login) { var getData = new Dictionary <string, string>(); getData.Add("sortBy", "id_asc"); getData.Add("titleId", gameId); _psnGameDetailsHtml = GetSourceCode(_psnGameDetailsUrl, getData: getData); }
/// <summary>Get the source code of the game details page</summary> /// <exception cref="ArgumentException">The gameId parameter is empty, null or only white spaces.</exception> /// <exception cref="ArgumentNullException">The the login parameter is null</exception> public void GetGameDetails(string gameId, Common.Login login) { if (string.IsNullOrEmpty(gameId) || string.IsNullOrWhiteSpace(gameId)) { throw new ArgumentException("This parameter cannot be empty, null or only white spaces.", "gameId"); } if (login == null) { throw new ArgumentNullException("login"); } //PingPageToGetCookies(); LoginPsn(login); GetGameDetailsSource(gameId, login); }
public void LoginPsn(Common.Login login) { //var getData = new Dictionary<string, string>(); //getData.Add("request_locale", "en_US"); //getData.Add("service-entity", "psn"); //getData.Add("returnURL", _loginReturnUrl); //var loginSource = GetSourceCode(_loginUrl, getData: getData); //var htmlDocument = new HtmlDocument(); //htmlDocument.LoadHtml(loginSource); //var strutsTokenName = htmlDocument.DocumentNode.SelectSingleNode("//input[@name='struts.token.name']").Attributes["value"].Value; //var strutsToken = htmlDocument.DocumentNode.SelectSingleNode("//input[@name='struts.token']").Attributes["value"].Value; var postData = new Dictionary <string, string>(); //postData.Add("struts.token.name", strutsTokenName); //postData.Add("struts.token", strutsToken); postData.Add("j_username", login.Username); //postData.Add("rememberSignIn", "on"); postData.Add("j_password", login.Password); //postData.Add("service-entity", "psn"); using (System.Net.HttpWebResponse httpWebResponse = (System.Net.HttpWebResponse)CreateHttpWebRequest(_loginUrl, postData: postData).GetResponse()) { if (httpWebResponse.Cookies["JSESSIONID"] == null) { throw new InvalidCredentialsException(); } _sessionId = httpWebResponse.Cookies["JSESSIONID"].Value; httpWebResponse.Close(); } var ticketUrl = string.Format(_ticketUrl, _sessionId); using (System.Net.HttpWebResponse httpWebResponse = (System.Net.HttpWebResponse)CreateHttpWebRequest(ticketUrl).GetResponse()) { httpWebResponse.Close(); } }