【这个问题已经发布在悬赏求助 http://ask.csdn.net/questions/239335,如有重复请版主酌情处理】
OANDA网站提供的REST API可以读取账户信息("https://api-fxtrade.oanda.com/v1/accounts),以及提供流报价(streaming,比如"https://stream-fxtrade.oanda.com/v1/prices?accountId=12345&instruments=AUD_CAD%2CAUD_CHF" )。目前在XE7版本,使用Delphi提供的RestClient组件可以实现读取账户信息。但是,对于服务端的流数据,由于其传输方式是 chunked transfer encoding,按照账户数据读取方式则会在停在最后Excute无法获得返回的Json字符串。代码如下: function GetStreamingPrices:TQJson
var
....
begin
Result := TQJson.Create;
// Get
_RESTRequest.Method := rmGET;
//指定资源位置:'/prices'
_RESTRequest.Resource := TRequestSourceURITemplate.Prices;
//生成query串:accountId=12345&instruments=AUD_CAD%2CAUD_CHF
_RESTRequest.AddParameter(TQueryPairKey.AccountID,accountlist[0],pkGETorPOST);
_RESTRequest.AddParameter(TQueryPairKey.Instruments,'EUR_USD',pkGETorPOST);
//URL
._RestClient.BaseURL := 'https://stream-fxtrade.oanda.com/v1';
//执行
_RestRequest.Execute;
//解析为Json
Result.tryParse(_RESTResponse);
end;so,请教,如何使用Delphi XE7 的RestClient 获取 chunked transfer encoding 的流数据?请不吝赐教。
OANDA网站提供的REST API可以读取账户信息("https://api-fxtrade.oanda.com/v1/accounts),以及提供流报价(streaming,比如"https://stream-fxtrade.oanda.com/v1/prices?accountId=12345&instruments=AUD_CAD%2CAUD_CHF" )。目前在XE7版本,使用Delphi提供的RestClient组件可以实现读取账户信息。但是,对于服务端的流数据,由于其传输方式是 chunked transfer encoding,按照账户数据读取方式则会在停在最后Excute无法获得返回的Json字符串。代码如下: function GetStreamingPrices:TQJson
var
....
begin
Result := TQJson.Create;
// Get
_RESTRequest.Method := rmGET;
//指定资源位置:'/prices'
_RESTRequest.Resource := TRequestSourceURITemplate.Prices;
//生成query串:accountId=12345&instruments=AUD_CAD%2CAUD_CHF
_RESTRequest.AddParameter(TQueryPairKey.AccountID,accountlist[0],pkGETorPOST);
_RESTRequest.AddParameter(TQueryPairKey.Instruments,'EUR_USD',pkGETorPOST);
//URL
._RestClient.BaseURL := 'https://stream-fxtrade.oanda.com/v1';
//执行
_RestRequest.Execute;
//解析为Json
Result.tryParse(_RESTResponse);
end;so,请教,如何使用Delphi XE7 的RestClient 获取 chunked transfer encoding 的流数据?请不吝赐教。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货