使用PHP cURL发送PUT请求 [英] Send PUT request with PHP cURL

查看:877
本文介绍了使用PHP cURL发送PUT请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想与每个请求中首先等待令牌的网络服务进行通信。
有我的问题,Web服务正在等待令牌通过 file_get_contenst(php:// input)


$ b b

我没有找到办法发送cURL请求trought这个方法(发送原始数据/ put数据而不是Post)。

 <$> 





c $ c> $ fp = fopen('php:// temp / maxmemory:256000','w');
fwrite($ fp,TOKEN);
fseek($ fp,0);
curl_setopt($ ch,CURLOPT_INFILE,$ fp); //文件指针
curl_setopt($ ch,CURLOPT_INFILESIZE,strlen($ json));
code>

 

解决方案

CURLOPT_PUT,true);



有关更多信息,您可以参考:如何在PHP中启动GET / POST / PUT / DELETE请求和判断请求类型?


I'm trying to communicate with a web service who's waiting first a token in each request. There is my problem, the web service is waiting the token throught file_get_contenst(php://input).

I didn't find a way to send cURL request trought this method (sending raw data/put data instead of Post). Could some one guides me ?

I tried something like :

$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);

For more info you can refer: How to start a GET/POST/PUT/DELETE request and judge request type in PHP?

这篇关于使用PHP cURL发送PUT请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆