Matlab中的curl命令
我正在尝试复制一个在unix计算机上运行良好的curl命令:Matlab中的curl命令,matlab,curl,Matlab,Curl,我正在尝试复制一个在unix计算机上运行良好的curl命令: curl-xpost--unsecure-H“内容类型:application/json“-H”“-d@ 我可以使用什么Matlab命令在Windows计算机上复制此命令?我正在努力找到一种方法来添加--unsecure选项 非常感谢让我们举个例子,我正在为emacs使用resclient,但不要为此感到害怕 我的目标是通过matlab调用: # # Request # :auth-token = abcd1234 :number :
curl-xpost--unsecure-H“内容类型:application/json“-H”“-d@
我可以使用什么Matlab命令在Windows计算机上复制此命令?我正在努力找到一种方法来添加--unsecure
选项
非常感谢让我们举个例子,我正在为emacs使用resclient,但不要为此感到害怕 我的目标是通过matlab调用:
#
# Request
#
:auth-token = abcd1234
:number := (+ 1 2 3 4)
:text := (concat "This is " ":num" "ber")
#
# Multiline variable referencing another variable
#
:common-headers = <<
Authentication: :auth-token
User-Agent: MyApp/1.0
Content-type: application/json
#
# ...and another one
:common-body = <<
{ "number": :number, "text": ":text" }
#
# Now, use them both in request
#
POST http://httpbin.org/post?q=1
:common-headers
:common-body
让我们将其转换为卷曲:
curl -i -H 'Content-type: application/json' -H 'User-Agent: MyApp/1.0' -H 'Authentication: abcd1234' -XPOST 'http://httpbin.org/post?q=1' -d '{ "number": 10, "text": "This is 10" }'
最后把它翻译成matlab,我建议你使用urlread2,这是MatlabFileExchange的matlab程序,你只需要注册就可以下载它。它是由Jim Hokason制作的,适用于最新的matlab版本(2016年),您可以
因此,使用来自的URLEAD2
上述请求可以是:
>> %% Create the headers
>> hct = http_createHeader('Content-Type','application/json');
>> hua = http_createHeader('User-Agent','matlab');
>> ha = http_createHeader('Authentication','abcd1234');
>> %% method
>> method = 'POST';
>> body = '{"number":10, "text: "this is 10"}';
>> x = urlread2('http://httpbin.org/post?q=', method, body, [hct hua ha])
x =
{
"args": {
"q": ""
},
"data": "{\"number\":10, \"text: \"this is 10\"}",
"files": {},
"form": {},
"headers": {
"Accept": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2",
"Authentication": "abcd1234",
"Content-Length": "34",
"Content-Type": "application/json",
"Host": "httpbin.org",
"User-Agent": "matlab"
},
"json": null,
"origin": "46.222.44.201",
"url": "http://httpbin.org/post?q="
}
对于不安全选项,我不认为这个验证ssl证书将运行systems命令窗口中的任何命令
>> %% Create the headers
>> hct = http_createHeader('Content-Type','application/json');
>> hua = http_createHeader('User-Agent','matlab');
>> ha = http_createHeader('Authentication','abcd1234');
>> %% method
>> method = 'POST';
>> body = '{"number":10, "text: "this is 10"}';
>> x = urlread2('http://httpbin.org/post?q=', method, body, [hct hua ha])
x =
{
"args": {
"q": ""
},
"data": "{\"number\":10, \"text: \"this is 10\"}",
"files": {},
"form": {},
"headers": {
"Accept": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2",
"Authentication": "abcd1234",
"Content-Length": "34",
"Content-Type": "application/json",
"Host": "httpbin.org",
"User-Agent": "matlab"
},
"json": null,
"origin": "46.222.44.201",
"url": "http://httpbin.org/post?q="
}