procedure TForm1.Button1Click(Sender: TObject);
var
postList: TStrings;
Response: TStringStream;
begin;
Response := TStringStream.Create('');
postList := TStringList.Create;
try
IdHTTP1.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Maxthon)';
postList.Add('id=admin');
postList.Add('ps=1');
IdHTTP1.Post('http://www.zhezhisd.cn/admin_in.asp',postList,Response);
finally
Memo1.Lines.Text := Response.DataString;
Response.Free;
postList.Free;
end;
end;
我寫成這樣就可以:
IdHTTP1.Post('http://www.zhezhisd.cn/admin_in.asp/?id=admin&ps=1',postList,Response);
而象上面那樣提交就不成功。請問是為什么?post的第二個引數不是用來提交一些引數的嗎?
uj5u.com熱心網友回復:
后面引數的字串是id=admin&ps=1,你Add引數的時候這個 & 怎么不見了?uj5u.com熱心網友回復:
學習一下。.............uj5u.com熱心網友回復:
這個要看服務器決議的。uj5u.com熱心網友回復:
樓主這里使用的是TStringList.在ADD的時候自動就會加上&符號了.
如果是TStringStream的ADD的話,則必須要加上&
樓主看下你的HTTP頭是否有問題,還有,你的網址根本打不開,想測驗都沒辦法幫你!
從代碼上看,是沒有問題.
uj5u.com熱心網友回復:
IdHTTP1.Post('http://www.qsyou.com/login.php?username=1008&password=123456',postList,Response);試試看
uj5u.com熱心網友回復:
請教!怎么用IDhttpuj5u.com熱心網友回復:
IdHTTP1.Post(url,postList);這樣就可以了
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/154576.html
標籤:網絡通信/分布式開發
