目录

秘钥

define("SYNC_TOKEN", "ycb-Wo*3@05#B50#")

请求

GET 请求

index.php?mod=api&act=menu&opt=update&tid=12&subject=可乐&costprice=3.00

POST 请求

index.php?mod=api&act=menu&opt=update

post 数组

[tid => 12,subject => 可乐, costprice => 3.00]

获取 sign

1.构建参数数组

[
    'mod' => 'api',
    'act' => 'menu',
    'opt' => 'update',
    'tid' => '12',
    'subject' => '可乐',
    'costprice' => '3.00',
]

2.按键升序排序

[
        'act' => 'menu',
        'costprice' => '3.00',
        'mod' => 'api',
        'opt' => 'update',
        'subject' => '可乐',
        'tid' => '12',
]

3.按顺序拼接成字符串

$str = 'menu3.00apiupdate可乐12';

4.使用秘钥和  HmacSHA1  方式加密

$sign = hash_hmac('sha1',$str,SYNC_TOKEN);

发送请求

GET 请求

index.php?mod=api&act=menu&opt=update&tid=12&subject=可乐&costprice=3.00&sign=xxxxxxxxxxxxxxx

POST 请求

index.php?mod=api&act=menu&opt=update

post 数组

[tid => 12,subject => 可乐, costprice => 3.00,sign => xxxxxxxxxxxxxx]