我想提交我的twitter登錄名和密碼與c#和一些http代碼。填充html輸入元素並提交表格
我有這樣的HTML代碼:
<div class="row password error">
<label for="password" tabindex="-1">Password</label>
<input aria-invalid="true" aria-required="true" autofocus="autofocus" class="password text" id="password" name="session[password]" type="password" value="" />
</div>
,我試圖做出這樣的迴應:
var encoding = new ASCIIEncoding();
var postData = ("password=" + Social);
byte[] data = encoding.GetBytes(postData);
var myRequest = (HttpWebRequest)WebRequest.Create(url);
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
myRequest.AllowAutoRedirect = true;
var newStream = myRequest.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
var response = myRequest.GetResponse();
var responseStream = response.GetResponseStream();
var responseReader = new StreamReader(responseStream);
var result = responseReader.ReadToEnd();
return result;
但你可以看到從輸入控件的名稱是會話[密碼],也許是問題,如果是這樣,我怎麼才能正確輸入密碼並提交此表單。
UPDATE小提琴結果:http://pastebin.com/raw.php?i=AcG8HUKj 謝謝。
'name =「session [password]」'這看起來相當奇怪,更不用說我認爲你需要使用'asp指令,比如'<% %>' – MethodMan 2015-02-09 19:44:34
我沒有擁有該頁面(twitter),我正在訪問它從桌面應用程序。 – PNCDJS 2015-02-09 19:48:42
好吧..你有沒有通過實際的代碼在你的端來檢查值等...你是否在步進通過代碼時得到任何錯誤。也不是關於訪問他們的網頁或不是..如果你寫了aspx標記..然後你應該知道和或理解如何使用正確的標籤,因爲我在我的初始問題中問...另一件事是在哪裏你是否傳遞了似乎是問題的證書?我會做更多的研究,以瞭解如何將用戶密碼憑證傳遞給使用C#的Twitter帳戶.net – MethodMan 2015-02-09 19:57:31