uses IdHashMessageDigest,IdHTTP,IdSSLOpenSSL,HTTPApp;
lv_sPosCmd := TStringList.Create;
lv_sPosCmd.Add('appCode=' + g_sAppCode);
lv_sPosCmd.Add('service=' + C_SERVICE_QUERY_STOCK_DAY);
lv_sPosCmd.Add('msgBody=' + lv_sMsgBody);
lv_sPosCmd.Add('sign=' + lv_sSign);
lv_sPosCmd.Add('requestTime=' + lv_sTime);
lv_sPosCmd.Add('batchNo=' + lv_sBatchNo);
MyWriteLog('提交接口数据:' + StringReplace(lv_sPosCmd.Text,#$D#$A,',',[rfReplaceAll]));
function PostData(const pviUrl: string; const pviData: TStringList; var pvoData, lv_sMsg: string): Boolean;
var
idHttp: TIdHTTP;
begin
Result := False;
try
pvoData := '';
lv_sMsg := '默认提示消息!';
idHttp := TIdHTTP.Create(nil);
try
idHttp.Request.ContentType := 'application/x-www-form-urlencoded'; ///json
idHttp.Request.ContentEncoding := 'utf-8';
pvoData := Utf8ToAnsi(idHttp.Post(pviUrl, pviData));
Result := True;
finally
FreeAndNil(idHttp);
end;
except
on E: Exception do
begin
lv_sMsg := '提交URL接口异常:' + #13#10 + e.Message;
MyWriteLog(lv_sMsg);
Exit;
end;
end;
end;