我使用突觸庫lib,我想通過http post發送一個字符串到PHP Api。如何發送帶有突發鏈接庫的http post的json字符串?
這是我最終的json字符串,我想通過http post發送到API。
{"os":"Windows7", "architecture":"64", "date":"20.06.2013", "version": "3.22", "name":"TestVM-PC"}
var sSendString: String;
sSendString := '{"os":"Windows7", "architecture":"64", "date":"20.06.2013", "version": "3.22", "name":"TestVM-PC"}';
我發現這個樣本程序後的參數,但我不知道現在怎麼樣正確地發送一個JSON字符串(sSendString)的API。
procedure HTTPPost;
var URL: string;
Params: string;
Response: TMemoryStream;
begin
Response := TMemoryStream.Create;
try
URL := 'http://testserver.com/api/add_customer';
Params := 'parameter1=' + EncodeURLElement('data1') + '&' +
'parameter2=' + EncodeURLElement('data2');
if HttpPostURL(URL, Params, Response) then
Response.SaveToFile('c:\response.txt');
finally
Response.Free;
end;
end;
所以有人可以幫我fixx我的問題,並展示我不得不改變我的JSON字符串發送到API,它線條。在此先感謝
您將使用http嗅探器來檢查您的程序是否符合HTTP規範,關於編碼和任何內容。 http://stackoverflow.com/questions/17198859/file-upload-on-wamp-or-xampp-locahost-server-without-the-script#comment24929798_17198859你也沒有指定什麼數據類型是'字符串',也沒有指定德爾福問題。閱讀這些評論,它們或多或少地適用於您的案例 –