Nehmen wir ein Beispiel verwenden, um hinzuzufügen, ich bin für Emacs resclient, aber nicht für das
Mein Ziel beängstigend erhalten ist diesen Aufruf mit Matlab amke:
#
# 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
das Ergebnis ist:
{
"args": {
"q": "1"
},
"data": "{ \"number\": 10, \"text\": \"This is 10\" }",
"files": null,
"form": null,
"headers": {
"Accept": "*/*",
"Accept-Charset": "utf-8;q=1, gb2312;q=0.5, iso-8859-1;q=0.5, big5;q=0.5, iso-2022-jp;q=0.5, shift_jis;q=0.5, euc-tw;q=0.5, euc-jp;q=0.5, euc-jis-2004;q=0.5, euc-kr;q=0.5, us-ascii;q=0.5, utf-7;q=0.5, hz-gb-2312;q=0.5, big5-hkscs;q=0.5, gbk;q=0.5, gb18030;q=0.5, iso-8859-5;q=0.5, koi8-r;q=0.5, koi8-u;q=0.5, cp866;q=0.5, koi8-t;q=0.5, windows-1251;q=0.5, cp855;q=0.5, iso-8859-2;q=0.5, iso-8859-3;q=0.5, iso-8859-4;q=0.5, iso-8859-9;q=0.5, iso-8859-10;q=0.5, iso-8859-13;q=0.5, iso-8859-14;q=0.5, iso-8859-15;q=0.5, windows-1250;q=0.5, windows-1252;q=0.5, windows-1254;q=0.5, windows-1257;q=0.5, cp775;q=0.5, cp850;q=0.5, cp852;q=0.5, cp857;q=0.5, cp858;q=0.5, cp860;q=0.5, cp861;q=0.5, cp863;q=0.5, cp865;q=0.5, cp437;q=0.5, macintosh;q=0.5, next;q=0.5, hp-roman8;q=0.5, adobe-standard-encoding;q=0.5, iso-8859-16;q=0.5, iso-8859-7;q=0.5, windows-1253;q=0.5, cp737;q=0.5, cp851;q=0.5, cp869;q=0.5, iso-8859-8;q=0.5, windows-1255;q=0.5, cp862;q=0.5, iso-2022-jp-2004;q=0.5, cp874;q=0.5, iso-8859-11;q=0.5, viscii;q=0.5, windows-1258;q=0.5, iso-8859-6;q=0.5, windows-1256;q=0.5, iso-2022-cn;q=0.5, iso-2022-cn-ext;q=0.5, iso-2022-jp-2;q=0.5, iso-2022-kr;q=0.5, utf-16le;q=0.5, utf-16be;q=0.5, utf-16;q=0.5, x-ctext;q=0.5",
"Authentication": "abcd1234",
"Content-Length": "38",
"Content-Type": "application/json",
"Extension": "Security/Digest Security/SSL",
"Host": "httpbin.org",
"Mime-Version": "1.0",
"User-Agent": "MyApp/1.0"
},
"json": {
"number": 10,
"text": "This is 10"
},
"origin": "46.222.44.201",
"url": "http://httpbin.org/post?q=1"
}
// POST http://httpbin.org/post?q=1
// HTTP/1.1 200 OK
// Server: nginx
// Date: Mon, 13 Feb 2017 10:29:40 GMT
// Content-Type: application/json
// Content-Length: 1768
// Connection: keep-alive
// Access-Control-Allow-Origin: *
// Access-Control-Allow-Credentials: true
// Request duration: 0.613051s
Sagen wir es zu einer Locke verwandeln:
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" }'
und es schließlich Matlab übersetzen zu empfehle ich Ihnen, diese zu verwenden urlread2 ist ein Matlab-Programm von Matlab fileexchange Sie können sich registrieren und Sie es dowload.
>> %% 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="
}
Für die unsichere Option I: es wurde von Jim Hokason, für den letzten Matlab Versionen (2016) Sie try this
So mit urlread2 von here
die obige Anfrage könnte dies gemacht kann glaube nicht, dass dies überprüfen ssl certifiactes
"system" wird jeden Befehl im Systembefehlsfenster ausführen –