将所有 curl 参数写在一个单独的文件中以在 web 服务上执行 multipart/form-data 请求

write all the curl arguments in a separate file to execute multipart/form-data request on webservices

我需要将所有 curl 参数写入一个单独的文件 (myconfig.txt) 中,以便在 output.txt、output1.txt、[= 中为每个不同的命令行执行和输出24=]...等等。 应使用 post (multipart/form-data) 方法请求 Web 服务。 我正在尝试这个命令 curl -K myconfig.txt -o output.txt

的内容

myconfig.txt include URL="http://1x2.2x1.x6.1x2:3000/latto/get_notifications"<option="to";mobile="+91999xx6xx3x"> into the output.txt - 'Cannot get /latto/get_notifications'. It seems like web-services are being requested as get method. Please anyone tell me the syntax to write in myconfig file. So that I can get the right output in file.


然而,当我运行这个命令sudo curl --form option="to" --form mobile="+9199999yyyxx" 1x2.2x1.x6.1x2:3000/latto/get_notifications时,输出在终端成功打印。

当我使用包含以下内容的 config.txt 执行 curl -k config.txt 时:

URL="http://my.test.domain/index.php"
-d option="to"
-d mobile="+91999xx6xx3x"

我得到结果:

POST
array(2) {
  ["option"]=>
  string(4) ""to""
  ["mobile"]=>
  string(15) "" 91999xx6xx3x""
}

所以我不知道你说的 <option ...> 是什么意思,但是当你如上所述将它放入你的配置文件时,它应该可以工作。

顺便说一句。这是回答的 php 脚本:

<?php
echo $_SERVER['REQUEST_METHOD']."\n";
var_dump($_REQUEST);
?>

此网络服务接受 POST 方法和加密类型 multipart/form-data

中的请求
    URL="http://my.test.domain/get_notifications"
    -F option=to
    -F mobile=+91999xx6xx3x

经过大量的尝试和尝试,我得到了这个工作:curl -k config.txt 和 config.txt 包含以上内容。