在Delphi中调用API接口的方法如下:
uses IdHTTP; procedure CallAPI; var HTTP: TIdHTTP; Response: string; begin HTTP := TIdHTTP.Create(nil); try Response := HTTP.Get('http://api.example.com/api_endpoint'); // 处理接口返回的响应数据 finally HTTP.Free; end; end; uses System.Net.HttpClient; procedure CallAPI; var HTTP: TNetHTTPClient; Response: string; begin HTTP := TNetHTTPClient.Create(nil); try Response := HTTP.Get('http://api.example.com/api_endpoint'); // 处理接口返回的响应数据 finally HTTP.Free; end; end; 以上示例中的URL应替换为实际的API接口地址,根据需要可以使用GET、POST等不同的HTTP请求方法。处理接口返回的响应数据的方式视具体业务需求而定。