Appearance
Http Method
- Requests use
http-post-formencodingapplication/x-www-form-urlencoded - Responses use
JSONencodingapplication/json
sample code
php
function md5_sign($data,$key){
ksort($data);
$string = http_build_query($data);
$string = urldecode($string);
$string=trim($string) . "&key=" . $key;
return strtoupper(md5($string));
}
function http_post($url, $data = null){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if (!empty($data)) {
curl_setopt($ch, CURLOPT_POST, 1);
$data = http_build_query($data);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_DEFAULT);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
$outPut = curl_exec($ch);
$aStatus = curl_getinfo($ch);
curl_close($ch);
if (intval($aStatus['http_code']) != 200) {
return "http code from server is not 200"
}
return $outPut;
}
$url = "...";
$params = [
"order_sn"=>time(),
"app_id"=>"..."
];
$sign = md5_sign($params); // see previous page
$payload['sign'] = $sign;
$res = http_post($url, $payload);
$res = json_decode($res, true);