| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 | <?php/** * 发短信 * @copyright 引擎力 * @author lc * @since 2020-09-17 */namespace App\Http\Services;use GuzzleHttp\Client;class SendMessageService{    /**     * 发送短信通知     * @param $mobile     * @param $keyWold     * @param int $type     */    public function sendMessage($mobile, $keyWold, $type = 1)    {        if ($type == 1) {            $tpl = 'SMS_228115546';//亲!后台新增了 {keyword} 关键词 需要进行分析,请及时处理喔~        } elseif ($type == 2) {            $tpl = 'SMS_228117817';//亲!${keyword} 的关键词数据已经生成请在后台查看。        } else {            $tpl = 'SMS_228142587';//亲!您有一条 ${keyword} 的关键词查询任务。        }        $url = 'http://translate.api.yinqingli.net/openapi/Msg/Msg';        $data = [            'mobile' => $mobile,            'tpl' => $tpl,            'TemplateParam' => [                'keyword' => $keyWold,            ],        ];        $client = new Client();        $response = $client->post($url, [            'form_params' => $data,        ]);        $response->getBody()->getContents();    }}
 |