Fx.http/http

HTTP GET请求,示例:

Fx.http.get( <String url>,  [<Map headers>])

def (Boolean error, HttpResult data,String errorMessage) =  Fx.http.get("http://www.fxiaoke.com",["X-token":"myToken"])

或:

http.get( <String url>,  [<Map headers>])

def (Boolean error, HttpResult data,String errorMessage) =  http.get("http://www.fxiaoke.com",["X-token":"myToken"])

返回值data类型为:HttpResult 属性有:statusCode、content

log.info(data.statusCode);
log.info(data.content);

其中content属性类型为String/Map,根据HTTP返回头Content-Type中是否包含application/json来决定content类型,True是Map,False是String;

HTTP POST请求,示例:

Fx.http.post( <String url>,  [<Map headers>],  [<Map/String data>])

def (Boolean error, HttpResult data,String errorMessage) =  Fx.http.post("http://www.fxiaoke.com",["X-token":"myToken"],["id":1])

或:

http.post( <String url>,  [<Map headers>],  [<Map/String data>])

def (Boolean error, HttpResult data,String errorMessage) =  http.post("http://www.fxiaoke.com",["X-token":"myToken"],["id":1])

返回值data类型为:HttpResult 属性有:statusCode、content

log.info(data.statusCode);
log.info(data.content);

其中content属性类型为String/Map,根据HTTP返回头Content-Type中是否包含application/json来决定content类型,True是Map,False是String;

results matching ""

    No results matching ""