PHP怎么发送json类型的CURL请求?

已邀请:

zkbhj - 凯冰科技站长

赞同来自:

use linslin\yii2\curl\Curl;

$curl = new Curl();
$paramsTo = array(
'data' =>array(
'name' => $name
),
);
$curl->setOption(CURLOPT_HTTPHEADER, array('Content-Type:application/json','Accept:application/json'));
$curl->setOption(CURLOPT_POSTFIELDS, json_encode($paramsTo));
$return_result = $curl->post($url);
$return_result = json_decode($return_result,true);

要回复问题请先登录注册