Curl_exec () removing the last 2-digit digit

I use the softtouch API with WordPress and post data to the API via curl.

But in response, I cannot send a large integer value to the function. I do not understand what the problem is with the data type or freeze.

Below is my code:

//create reservation
$prod_items = array();
$single_item = array('product_uid'=>11449701010101);
$prod_items[] = $single_item;

$res_params = array(
    'customer_id' => 1111,
    'payment_type' => '',
    'invoice_address_id' => 123,
    'delivery_address_id' => 142,
    'giftlist_id' => '',
    'store_id' => '',
    'items' => $prod_items
);
$res_url = $base_url . 'reservations';    
$res_content = json_encode($res_params);

$res_curl = curl_init();
curl_setopt($res_curl, CURLOPT_HTTPHEADER, array('Authorization: ' . $authToken, 'Content-Type: application/json'));
curl_setopt($res_curl, CURLOPT_POST, true);
curl_setopt($res_curl, CURLOPT_POSTFIELDS, $res_content);
curl_setopt($res_curl, CURLOPT_URL, $res_url);
curl_setopt($res_curl, CURLOPT_RETURNTRANSFER, true);

$res_response = curl_exec($res_curl);

if ($res_response === FALSE)
die(curl_error($res_curl));
curl_close($res_curl);
$res_array = json_decode($res_response);

When sending data to a function, curl_exec()it deletes the last two digits product_uid, since I passed it 11449701010101, it sends it as 114497010101.

Is this an integer range problem or something like a curl function?

+4
source share
1 answer

tl: dr It would seem that there is something else (in the script processing the CURL request) that is truncating product_uid. (?)

array('product_uid'=>11449701010101)

32- (PHP 32- ), 11449701010101 32- . PHP float, .

json_encode($res_params);

PHP json_encode() respresentation ( JSON). . 11449701010101 .

curl_exec()

(POST) , .

script JSON, , . product_uid - float, ( ).

11449701010101 (, (int)11449701010101), -681801035 - . , , - ?

, , , - ( ), , , . (?)

0

Source: https://habr.com/ru/post/1662128/


All Articles