使用 easysms 发送短信,提示 All the gateways have failed?

我用的aliyun,配置好参数后,测试,返回的错误是All the gateways have failed.
部分代码如下(模板我擦掉了)
阿里云确定是可用的

try{
            $result = $easySms->send($phone, [
                'template' => 'SMS_######',
                'data' => [
                    'code' => $code
                ],
            ],['aliyun']);
        }catch (\GuzzleHttp\Exception\ClientException $exception){
            $response = $exception->getResponse();
            $result = json_decode($response->getBody()->getContents(), true);
            return $this->response->errorInternal($result['msg']??'短信发送异常');
        }
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 11
liyu001989

仔细看一下 easy-sms 的文档。阿里云需要使用模板加数据的方式调用

短信内容使用 template + data

可能是这样
$easySms->send(13188888888, [
    'template' => 'SMS_001',
    'data' => [
        'code' => 6379
    ],
]);
6年前 评论

@liyu001989
是按照github上的文档做的,模板和数据都给了,现在的项目用的是aliyun官方的sdk写的,现在不知道问题出在哪里

6年前 评论
liyu001989

All the gateways have failed. 所有的 gateways 有错误,配置写错了吧
@山海王子 研究一下easy-sms 需要的配置吧。

6年前 评论

@liyu001989
我把扩展包里AliyunGateway.php里定义的常量修改了一下

 const ENDPOINT_URL = 'http://这里改成了我的服务结点';

现在会正常报错(我定义的报错'短信发送异常'),可是还是不知道哪里的问题

"debug": {
        "line": 173,
        "file": "/home/vagrant/Code/api.test.com/vendor/dingo/api/src/Http/Response/Factory.php",
        "class": "Symfony\\Component\\HttpKernel\\Exception\\HttpException",
        "trace": [
略...
6年前 评论
liyu001989

easy-sms 的 issues 里面找找看,或许是个bug,有兴趣的话可以研究研究,提个pr :smile:

我没用过阿里云的,手上也没账号,可能帮不了你

6年前 评论

@liyu001989
找到问题了...

$easySms->send(13188888888, [
    'template' => 'SMS_001',
    'data' => [
        '这里的变量名称为阿里云上定义的变量' => 6379
    ],
]);
6年前 评论
JupiterK

我也是使用 aliyun 配置好了,但是还是遇到这个提示 All the gateways have failed 。然后我放弃用这个插件,用其他插件发现是我虚拟机里的时间是错误的,修正服务器时间后,再用这个插件就可以发送了。

5年前 评论
小花儿

@JupiterK 请问aliyun怎么配置的

5年前 评论
小花儿

@山海王子 大佬,请问阿里云怎么配的

5年前 评论

$easySms->send($phone,[
'template'=>'SMS_129995088',
'data'=>[
'code'=>$code
]
]); 我之前因为阿里云这里的配置写错了,导致了500错误All the gateways have failed.仅此mark一下

4年前 评论

很有可能是时间问题;linux系统下 date确认下时间是否正确

4年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!