cmbYouku_Api/app/service/util/BlueBrothersClientUtil.php

28 lines
793 B
PHP
Raw Permalink Normal View History

2024-07-01 15:57:07 +08:00
<?php
declare (strict_types=1);
namespace app\service\util;
use app\exception\BusinessException;
use BlueBrothers\Openapi\Api\Client;
use think\facade\Log;
/**
* @author canny
* @date 2024/3/11 9:48
**/
class BlueBrothersClientUtil
{
public static function getClient(): Client
{
$merchantId = env('blue_brother.merchant_id', 23329);
$secretKey = env('blue_brother.secret_key', '8db16e8cc8363ed4eb4c14f9520bcc32');
$prodFlag = env('blue_brother.is_prod', false);
try {
return new Client($merchantId, $secretKey, $prodFlag, 10);
} catch (\Exception $e) {
Log::error("蓝色兄弟api客户端初始化失败:" . $e->getMessage());
throw new BusinessException('客户端初始化失败.');
}
}
}