在php上发送带有Curl的put命令

时间:2016-11-30 00:27:33

标签: php curl put

给出以下shell命令:

curl -X PUT -d arg1='value1'-d arg2='value2' -d arg3='value3' \
https://api.myurl/1/subscriptions/1234;

什么是PHP Curl等价物?

1 个答案:

答案 0 :(得分:2)

结帐此网站:https://incarnate.github.io/curl-to-php/

创建了这个:

// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "arg2='value2'");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "arg1='value1'-d&arg3='value3'");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");


$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close ($ch);