PHP cURL, POST JSON

后端 未结 5 2283
南方客
南方客 2020-11-28 13:48

I need to POST the following JSON code, but for some reason it is not working. Below is the code that I have.

$fieldString = \"395609399\";
//the curl reques         


        
5条回答
  •  天命终不由人
    2020-11-28 14:14

    I had issues sending JSON via cURL, and the problem was that I was not explicitly setting the content length in the header.

    So the Header should be:

    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($json)));
    

提交回复
热议问题