好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

PHP如何实现阿里云短信sdk灵活应用在项目中的方法

首先安装 composer require alibabacloud/sdk https://packagist.org/packages/alibabacloud/sdk $code ]; AlibabaCloud::accessKeyClient($config['accessKeyId'], $config['accessSecret']) ->regionId($config['regionId']) ->asGlobalClient(); try { $result = AlibabaCloud::rpcRequest() ->product('Dysmsapi') ->version('2017-05-25') ->action('SendSms') ->method('POST') ->options([ 'query' => [ 'PhoneNumbers' => $phone, 'SignName' => $config['SignName'], 'TemplateCode' => $config['TemplateCode'], 'TemplateParam' => json_encode($param) ], ]) ->request(); return $result->toArray(); } catch (ClientException $e) { echo $e->getErrorMessage() . PHP_EOL; } catch (ServerException $e) { echo $e->getErrorMessage() . PHP_EOL; } } } include 'My_composer_aliyunsms.php'; $sms = new My_composer_aliyunsms(); $phone='xxxxxx'; $code='99999'; $config = [ 'accessKeyId' => 'LTAIMje******hS', 'accessSecret' => 'fMuQTLUrKQN******Z2m07', 'SignName' => '****', 'TemplateCode' => 'SMS_****04', 'regionId' => 'cn-hangzhou' ]; $re = $sms->sendCode($config,$phone,$code); var_dump($re);

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持自学php网。

查看更多关于PHP如何实现阿里云短信sdk灵活应用在项目中的方法的详细内容...

  阅读:47次