http://platform.okbuy.com/supplier/api/getDiffCatsOdrLists
$UserId = 你的ID;
$key = '你的密钥';//密钥,参与签名
//OrderCodes需要查询的订单号,最多不超过100个
$post_data = array (
"SignDate" => date('Y-m-d H:i:s'),
"UserId" => $UserId,
"Request" => json_encode(array('OrderCodes'=>array('121218394415'),'OrderDate'=>array('Start'=>'2012-10-10 10:10:10','End'=>'2012-12-20 10:10:10'),'Page'=>1))
);
//签名开始
$sign_data = 'SignDate='.$post_data['SignDate'].',Request='.$post_data['Request'];
$sign = hash_hmac("md5",$sign_data, $key);
//签名成功后将签名放入$post_data数组等待post传输
$post_data['Sign'] = $sign;
//签名完毕
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$outstr = curl_exec($ch);
curl_close($ch);
//echo $outstr;exit;
$response = json_decode($outstr,1);
//print_r($response);
//判断是否有错误
if ($response['ErrorCode'] > 0){
echo "ErrorCode:".$response['ErrorCode'].",ErrorMessage:".$response['ErrorMessage'];
exit;
}
//验签
$sign_data = 'SignDate='.$response['SignDate'].',Result='.$response['Result'];
$sign_new = hash_hmac("md5",$sign_data, $key);
//如果验签成功
if ($sign_new == $response['Sign']){
$result = json_decode($response['Result'],1);
print_r($result);
//var_dump($result);
} else {
echo "failure";
}