Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改yunxin无通知模板问题 #331

Open
xugames opened this issue May 12, 2022 · 1 comment
Open

修改yunxin无通知模板问题 #331

xugames opened this issue May 12, 2022 · 1 comment

Comments

@xugames
Copy link

xugames commented May 12, 2022

近日使用网易云信通知短信,报错,经检查无云信通知模板短信格式
做一下修改
`switch ($action) {
case 'sendCode':
$params = $this->buildSendCodeParams($to, $message, $config);

            break;
        case 'sendTemplate':
            $params = $this->buildSendMsgParams($to, $message, $config);
            break;
        case 'verifyCode':
            $params = $this->buildVerifyCodeParams($to, $message);

            break;
        default:`

新增sendTemplate 以及参数格式函数buildSendMsgParams
`public function buildSendMsgParams(PhoneNumberInterface $to, MessageInterface $message, Config $config)
{

    $data = $message->getData($this);
    $template = $message->getTemplate($this);
    
    if (!array_key_exists('params', $data)) {
        throw new GatewayErrorException('"params" cannot be empty', 0);
    }
    return [
        'mobiles' => json_encode([$to->getUniversalNumber()]),
        'templateid' => is_string($template) ? $template : '',
        'params'=>array_key_exists('params', $data) ? $data['params'] : '',
        'needUp' => $config->get('need_up', false),
    ];
}`

使用方法
$massage=[ 'template' => 'xxxx', 'data' => [ 'params' =>json_encode([$params]), 'action' => 'sendTemplate', ], ];

@overtrue
Copy link
Owner

欢迎 PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants