这是我想传递给CURLOPT_POSTFIELDS
的参数{"user":{"user_id":"346"}}
示例:
curl_setopt($ch, CURLOPT_POSTFIELDS, {"user":{"user_id":"346"}});
我怎么做?
感谢
答案 0 :(得分:1)
根据您的示例,您的数据为json
,因此您需要将数据传递为json string
$data_string = '{"user":{"user_id":"346"}}';
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
当你传递json时,将header设置为json application
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);