cURL JSON post 不工作并且没有显示错误 PHP 7

cURL JSON post not working and shows no error PHP 7

我有一个奇怪的错误,我在 PHP 7 中的 cURL 脚本似乎不起作用,并且没有给出错误。我的代码:

$content = json_encode(array(
    'I was just testing',
    'Whether or not this is working',
        ));

$collatex_url = 'http://localhost:7369/collate';
$collatex_headers = array(
    "Content-type: application/json; charset=UTF-8;",
    "Content-Length: " . strlen($content),
    "Accept: application/json"
);

$curl = curl_init($collatex_url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $collatex_headers);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, array('json' => $content));
//curl_setopt($curl, CURLOPT_POSTFIELDS, array('json=' . urlencode($content))); //tried, also does not work
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
echo curl_error($curl); //does not produce an error
echo 'THE RESULT IS' . $result; //the result is empty
curl_close($curl);

如有任何帮助,我们将不胜感激。

尝试像这样发送 json:

curl_setopt($curl, CURLOPT_POSTFIELDS, $content);