用Idhttp.post方法將客戶端的文本提交給服務器的範例

 var
   strMsg:string;
   sParams: TStringStream;
begin
  sParams := TStringStream.create('');
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
  try
    sParams.WriteString('參數1=結果&參數2=結果2') ;
    strMsg:=IdHTTP1.post('http://www.xxxxx.com/add-c.asp',sParams)  ;
    memo1.Text:=strmsg;
  finally
    sParams.Free ;
  end;
s := 'http://aaa.net/bbs/index.php';
  if CanGetIECookie(s, str) then
  begin
    CookieStr := 'Cookie: '   str;
    idHttp1.Request.CustomHeaders.Text := CookieStr;
  end else
  begin
    ShowMessage('沒有發現本地Cookie,請從Web頁面登陸一次。');
    Exit;
  end;
  s := 'http://aaa.net/bbs/forumdisplay.php';
  PostData := TStringList.Create;
  PostData.Add('fid=1');
  Memo1.Lines.Text := idHTTP1.Post(s, PostData);
  PostData.Free; 
var
  S:TStringList;
begin
  S := TStringList.Create;
  S.Add('user=', edtUser.text);
  S.Add('pass=', edtPass.text);
  try
    HTTP.Post('http://xxxxxxxx/xxx',  S);
  finally
    HTTP.Free;
  end;
end;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章