础笔滨技术讲解
- 8. PHP代码示例<?php
//设置你的APPKEY和secret
$appKey = 'test';
$appSecret = 'test';
//参数数组
$paramArr = array(
'app_key' => $appKey,
'method' => 'taobao.trades.sold.get',
'format' => 'json',
'v' => '2.0',
'sign_method' => 'md5',
'timestamp' => date('Y-m-d H:i:s'),
'fields' =>
'receiver_name,receiver_mobile,receiver_phone'
);
- 9. PHP代码示例
//生成签名
$sign = $appSecret;
ksort($paramArr);
foreach ($paramArr as $key => $val) {
if ($key !='' && $val !='') {
$sign .= $key.$val;
}
}
$sign.=$appSecret;
$sign = strtoupper(md5($sign));
//组织参数
$strParam = '';
foreach ($paramArr as $key => $val) {
if ($key != '' && $val !='') {
$strParam .= $key.'='.urlencode($val).'&';
}
}
$strParam .= 'sign='.$sign;