我的问题是我无法在命令行上运行PHP中的cURL。我的代码是这样的:
public function updateSolrProfilData($arrData)
{
$solrClientOptionsCommit = $this->solrClientOptionsYazProfilCommit;
$urlCommit = "http://" . $solrClientOptionsCommit['hostname'] . ":" . $solrClientOptionsCommit['port'] . "/" . $solrClientOptionsCommit['path'] . "/update?stream.body=%3Ccommit/%3E -H \"Content-Type: text/xml\" --data-binary '<add><doc>";
foreach ($arrData as $firmaField => $firmaValue)
{
if ( ! is_array($firmaValue))
{
$urlCommit = $urlCommit . '<field name="' . $firmaField . '">' . $firmaValue . '</field>';
}
else
{
foreach ($firmaValue as $firmaField2 => $firmaValue2)
{
if ('' != $firmaValue2)
{
$urlCommit = $urlCommit . '<field name="' . $firmaField . '">' . $firmaValue2 . "</field>";
}
}
}
}
$urlCommit .= "</doc></add>'";
$urlCommit = htmlspecialchars($urlCommit);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_URL, $urlCommit);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$data = curl_exec($ch);
curl_close($ch);
}
当我在命令行上运行它时,它可以工作,但是在使用cURL和PHP shell_exec函数时它不起作用。这有什么问题?