PHP code example of weiaibaicai / hupun
1. Go to this page and download the library: Download weiaibaicai/hupun library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
weiaibaicai / hupun example snippets
# open接口的key
HUPUN_OPEN_KEY=openAppKey
# open接口的秘钥
HUPUN_OPEN_SECRET=open秘钥
# open接口的请求域名
HUPUN_OPEN_URL=https://open-api.hupun.com/api
# open接口的消息通道
HUPUN_OPEN_LOG_CHANNEL=single
# 打印请求结果日志
HUPUN_OPEN_API_IS_LOG_RESULT=1
# b2c接口的key
HUPUN_B2C_KEY=b2cAppKey
# b2c接口的秘钥
HUPUN_B2C_SECRET=b2c秘钥
# b2c接口的请求域名
HUPUN_B2C_URL=https://erp-open.hupun.com/api
# b2c接口的消息通道
HUPUN_B2C_LOG_CHANNEL=single
# 打印请求结果日志
HUPUN_B2C_API_IS_LOG_RESULT=1
use Weiaibaicai\Hupun\Facades\Hupun;
use Weiaibaicai\Hupun\Client;
//调用单笔查询库存的接口
$params = [
'page' => 1,
'limit' => 20,
'start' => '2023-03-22 00:00:00',
'end' => '2023-03-29 00:00:00',
];
//调用的三种方式
dd(Hupun::getInventoriesErp($params));
dd(Client::make()->getInventoriesErp($params));
dd(Client::make()->execute('/inventories/erp', $params, 'get', false));
use Weiaibaicai\Hupun\Client;
//取出参数
$params = $request->all();
//验签
$sign = Arr::get($params, 'sign');
unset($params['sign']);
$client = (new Client())->make();
$client->useConfig('b2c');
$newSign = $client->generateSign($params);
if ($newSign === $sign) {
//todo: 去实现个人业务
}