开发项目中,遇到须要向第三方接口发送json数据数据的状况,php默认发送数据形式为text,须要告诉第三方接口数据形式为json,这时就须要执行下列代码修改http Content-Type头信息php
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json; charset=utf-8', 'Content-Length: ' . strlen($jsonStr) ) );
参考网址:https://www.cnblogs.com/52php/p/5677684.htmlhtml
https://blog.csdn.net/hai7425/article/details/70849448json