2010-07-01 3 views
1

.NET 양식 앱에서 HttpWebRequest를 사용하여 Amazon 판매자 센터 계정에서 주문 정보를 긁어내어 액세스하려고합니다..NET HttpWebRequest를 사용하여 Amazon 판매자 센터에 로그인

<html> 
<body> 
<form action="https://sellercentral.amazon.co.uk/gp/sign-in/sign-in.html/ref=ag_login_lgin_myo" method="post" name="signin"> 
    <input type="hidden" name="protocol" value="https" /> 
    <input type="hidden" name="action" value="sign-in" /> 
    <input type="text" name="email" value="[email protected]"/> 
    <input type="password" name="password" value="xxxxxx"/> 
    <input type="submit" name="sign-in-button"/> 
</form> 
</body> 
</html> 

을 내가 성공적으로 다시 아마존 홈페이지에 로그인 얻을 제출 : 나는 하드는 내가 IE에서이 지역의 HTML을 열 때문에 경우에 기록 얻을 것이 아니라는 것을 알고. 내가 무슨 일을하고 있어요

string sUrl = "https://sellercentral.amazon.co.uk/gp/sign-in/sign-in.html/ref=ag_login_lgin_myo"; 
string sPostData = ""; 
sPostData += "protocol=https"; 
sPostData += "&action=sign-in"; 
sPostData += "&[email protected]"; 
sPostData += "&password=xxxxxx"; 
sPostData += "&sign-in-button="; 

// initialise request object 
HttpWebRequest oRequest = (HttpWebRequest)WebRequest.Create(sUrl); 
oRequest.Timeout = 30000; 

// set fake headers 
oRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1)"; 

// set the method & content type 
oRequest.Method = "POST"; 
oRequest.ContentType = "application/x-www-form-urlencoded"; 

// prepare post data 
ASCIIEncoding encoding = new ASCIIEncoding(); 
byte[] byteArr = encoding.GetBytes(sPostData); 

// write to request 
oRequest.ContentLength = byteArr.Length; 
Stream reqStream = oRequest.GetRequestStream(); 
reqStream.Write(byteArr, 0, byteArr.Length); 
reqStream.Close(); 

// fetch the page 
HttpWebResponse oResponse = (HttpWebResponse)oRequest.GetResponse(); 

// convert response to a string 
StreamReader sr = new StreamReader(oResponse.GetResponseStream()); 
string responseHTML = sr.ReadToEnd().ToLower(); 
sr.Close(); 

어떤 아이디어 그러나 나는이 코드를 통해 동작하지 않습니다, 나는 항상 다시 대신 다시 로그인 페이지를 얻을, 여기에 코드? 아마존이 거부하고있는 IE를 통해 양식을 제출하는 것에 비해 내 HttpWebRequest 제출과 다른 무언가가 있어야 할 것 같지만 무엇을 알아낼 수 없습니까? 도움이 많이 감사 - 감사합니다.

답변

0

Amazon Web Services을 들여다 보았습니까? 당신은 여전히 ​​사용자가 원하는 방식으로 일을 주장하는 경우

그들은 또한 C# library

이 요청에 CookieContainer()를 설정해보십시오.

+0

이전 질문이지만 여전히 관련이 있습니다. AWS는 프로 판매자 만 사용할 수 있으며 (매월 사용료 포함) 모든 판매자 정보는 필요하지 않을 수도 있습니다. 쿠키 응답이 더 적합합니다. –

관련 문제