我正在尝试与网络服务通信,该网络服务首先在每个请求中等待 token 。
我的问题是,Web 服务正在通过 file_get_contenst(php://input)
等待 token 。
我没有找到通过这种方法发送 cURL 请求的方法(发送原始数据/放置数据而不是 Post)。 有人可以指导我吗?
我试过类似的东西:
$fp = fopen('php://temp/maxmemory:256000', 'w');
fwrite($fp, TOKEN);
fseek($fp, 0);
curl_setopt($ch, CURLOPT_INFILE, $fp); // file pointer
curl_setopt($ch, CURLOPT_INFILESIZE, strlen($json));
最佳答案
curl_setopt($ch, CURLOPT_PUT, true);
更多信息可以引用:How to start a GET/POST/PUT/DELETE request and judge request type in PHP?
关于php - 使用 PHP cURL 发送 PUT 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19257295/