curl命令行到php

时间:2013-01-11 19:07:46

标签: php linux curl

我有一个命令,我一直在转换为php。

curl -i -X POST -u user:userpass --ur http://cloud.netelignet.ca/virtual_machines/:virtual_machine_id/startup.xml

1 个答案:

答案 0 :(得分:0)

我认为它等同于以下内容:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://cloud.netelignet.ca/virtual_machines/:virtual_machine_id/startup.xml");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$username = 'user'; $password = 'userpass';
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_HEADER, 1);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);