卷曲不起作用,它显示一些错误。 输出: 排列 ( [status] =>错误 [msg] =>无效的Json格式 ) 但它适用于google chrome的POSTMAN扩展................
<?php
$key = 'd12121c70dda5edfgd1df6633fdb36c0';
$ttl = time();
$product_id = 389530;
$user_id = 2888765;
$password = 123456;
$cart_id = 3746357803;
$secret_key = md5($password);
$message = $key . $user_id . $ttl;
$token = hash_hmac('SHA256', $message, $secret_key);
$data = array("user_id" => "$user_id", "product_id" => "$product_id", "cart_id" => "$cart_id", "qty" => "2", "key" => "$key", "ttl" => "$ttl", "token" => "$token");
$data_string = json_encode($data);
echo $data_string;
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_URL, "https://example.com");
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // disable ssl check
$result = curl_exec($ch);
$output = json_decode($result,true);
echo curl_error($ch); //display error if any
curl_close($ch);
echo "<pre>";
print_r($output);
echo "</pre>";
?>