我一直在尝试使用REBOL的API访问该网站,但遇到了问题。API调用需要一个自定义头部和一个XML格式的请求。我一直在尝试使用read/custom,但我不确定如何包含头部,或者它应该采用什么格式。system/options/cgi中的默认头是一个对象,所以我假设它应该是一个对象,但是您应该把它放在哪里呢?(添加到system/options/cgi不起作用。)
我猜下面的代码是我需要的……
http-custom-header: make object! [
Content-Type: text/xml
etc...
]
xml-request: {
<?xml version="1.0" encoding="utf-8"?>
<etc>etc...<etc>
}
site-URL: http://etc...
response: read/custom site-URL reduce ['post xml-request]不过,这不会起作用,因为http-custom-header并没有放在任何有用的地方。
我在正确的轨道上吗?如果是这样的话,头部应该放在哪里?否则,使用REBOL发送HTML头和请求的可行方法是什么?
发布于 2012-01-01 20:09:25
我已经弄明白了。您只需将'header和一个块(而不是一个对象)添加到读取/自定义块中。
http-custom-header: [
Content-Type: text/xml
etc...
]
xml-request: {
<?xml version="1.0" encoding="utf-8"?>
<etc>etc...<etc>
}
site-URL: http://etc...
response: read/custom site-URL reduce [
'header http-custom-header
'post xml-request
]https://stackoverflow.com/questions/8691754
复制相似问题