overtrue / easy-sms

📲 一款满足你的多种发送需求的短信发送组件
MIT License
3.13k stars 543 forks source link

聚合短信的底层好像有问题,$config->get('app_key')拿不到key值 #223

Closed joeoeeee closed 4 years ago

joeoeeee commented 4 years ago

JuheGateway.php image 然后我只能改成这样才能使用:'key' => $config->get('app_key')?:env('JUHE_API_KEY');

overtrue commented 4 years ago

你的配置怎么写的啊

joeoeeee commented 4 years ago

你的配置怎么写的啊

1、.env JUHE_API_KEY=c1db012a4f19dxxxxxxx

Controller $config = [ // HTTP 请求的超时时间(秒) 'timeout' => 5.0, // 默认发送配置 'default' => [ // 网关调用策略,默认:顺序调用 'strategy' => \Overtrue\EasySms\Strategies\OrderStrategy::class, // 默认可用的发送网关 'gateways' => [ 'juhe', ], ], // 可用的网关配置 'gateways' => [ 'errorlog' => [ 'file' => '/tmp/easy-sms.log', ], 'juhe' => [ 'api_key' => env('JUHE_API_KEY'), ], ], ]; $easySms = new EasySms($config); try { $res = $easySms->send(180xxxxxxx0, [ 'content' => '这是一个测试2!', 'template' => '188299', 'data' => [ 'code' => 4321 ], ]); dd($res); } catch (\Overtrue\EasySms\Exceptions\NoGatewayAvailableException $exception) { $message = $exception->getResults(); dd($message); }

返回结果:100001,就是无key。 2、然后我去JuheGateway.php打印参数 image

打印结果:

array(5) {

  | ["mobile"]=>   | string(11) "180xxxxxx"   | ["tpl_id"]=>   | string(6) "188299"   | ["tpl_value"]=>   | string(15) "%23code%23=4321"   | ["dtype"]=>   | string(4) "json"   | ["key"]=>   | NULL   | }

说明app_key丢失 3、我猜测是config.php的get方法有瑕疵,当然我没有细看源码,昨天开始上手测试的。 image 4、最后,谢谢大大!!

overtrue commented 4 years ago
  1. 我文档里写的是叫 app_key
  2. 你的配置里写的是 api_key