使用Delphi调用Http POST url的最简单方法是什么? [英] What’s the simplest way to call Http POST url using Delphi?
本文介绍了使用Delphi调用Http POST url的最简单方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
受最简单的问题的启发使用Delphi调用Http GET url的方法?
我真的想看一下如何使用POST的示例。最好从通话中接收XML。
Inspired by the question What’s the simplest way to call Http GET url using Delphi? I really would like to see a sample of how to use POST. Preferably to receive XML from the call.
添加:在帖子数据中包含图像或其他文件怎么样?
Added: What about including an image or other file in the post data?
推荐答案
使用Indy。把你的参数放在一个StringList(name = value)中,只需用URL和StringList调用Post。
Using Indy. Put your parameters in a StringList (name=value) and simply call Post with the URL and StringList.
function PostExample: string;
var
lHTTP: TIdHTTP;
lParamList: TStringList;
begin
lParamList := TStringList.Create;
lParamList.Add('id=1');
lHTTP := TIdHTTP.Create(nil);
try
Result := lHTTP.Post('http://blahblahblah...', lParamList);
finally
lHTTP.Free;
lParamList.Free;
end;
end;
这篇关于使用Delphi调用Http POST url的最简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文