在后场传递价值。 PHP

this is my parameter i want to pass in CURLOPT_POSTFIELDS

{"user":{"user_id":"346"}}    

example :

curl_setopt($ch, CURLOPT_POSTFIELDS, {"user":{"user_id":"346"}});

how i can do it ?

thanks

As per your example your data is json so You need to pass data as json string

$data_string = '{"user":{"user_id":"346"}}';
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);

Also when you pass json, set header as json application

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