简体   繁体   English

需要帮助来转换cURL命令行以从PHP文件运行

[英]Need help to convert cURL Command Line to run from PHP file

The cURL command that I run from the command line is: 我从命令行运行的cURL命令是:

curl --digest -u "username:password" "http://[ip-address]:8086/streammanager/streamAction?action=resetStream" --data "vhostName=_defaultVHost_&appName=rtr_planeta/_definst_&streamName=rtr_planeta.stream"

The problem I am facing is with the following part of the command: 我面临的问题是命令的以下部分:

 --data "vhostName=_defaultVHost_&appName=rtr_planeta/_definst_&streamName=rtr_planeta.stream"

Where in PHP code do I specify --data ? 我在PHP代码的哪里指定 --data

I got this far: 我已经走了这么远:

<?php
$url="http://[ip-address]:8086/streammanager/streamAction?action=resetStream";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);    
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); 
curl_setopt($ch, CURLOPT_USERPWD, 'username:password');
$result = curl_exec($ch);

if(curl_errno($ch))
{
  echo 'Curl error: ' . curl_error($ch);
}
else
{    
  echo $result;
}

curl_close($ch);
?>
$param = 'vhostName=_defaultVHost_&appName=rtr_planeta/_definst_&streamName=rtr_planeta.stream';
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $param);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM