I used Alibaba Cloud’s new communication SDK by integrating the SDK to the composer for installation.
Class loading worked fine, but an error was prompted at the following stage:
//acsCleint of initialization access
$profile = DefaultProfile: :getProfile($re gion, $accessKeyId, $accessKeySecre t);
DefaultProfile: :addEndpoint("c n-hangzhou","cn-hangzhou", $product, $domain);
Error message:

It outputs the message. The self::$endpoint s value is “null”.
The complete code of my function is as follows:
public function smsNew($data=[]){
//Replace the value here with your own AK
$accessKeyId = Config::get('al idayu.appkey');
$accessKeySecre t = Config::get('al idayu.secretKey ');
//Name of the text message API product (The text message product name is fixed and does not require modification.)
$product = "Dysmsapi";
//Domain name of the text message API product (The interface address is fixed and does not require modification.)
$domain = "dysmsapi.aliyu ncs.com";
//Multiple regions are not supported yet (Only cn-hangzhou is supported for now. Do not change it.)
$region = "cn-hangzhou";
//acsCleint of initialization access
$profile = DefaultProfile: :getProfile($re gion, $accessKeyId, $accessKeySecre t);
DefaultProfile: :addEndpoint("c n-hangzhou","cn-hangzhou", $product, $domain);
$acsClient= new DefaultAcsClien t($profile);
$request = new SendSmsRequest( );
$request->setPhoneNumber s($data['mobile']);
//Required – text message signature
$request->setSignName(Co nfig::get('alid ayu.FreeSignNam e'));
//Required – text message template code
$request->setTemplateCod e($data['template']);
//Optional – required if the template contains a variable that should be replaced (JSON format)
$request->setTemplatePar am(json_encode( $data['param']));
//Optional – Send the text message serial number
// $request->setOutId("1234 ");
//Initiate an access request
$acsResponse = $acsClient->getAcsResponse ($request);
dump($acsRespon se);
return $acsResponse;
}
My accesskey and secretKey are generated at the Access Key administration and are available.
I ran a test just now and it turned out that text message could be sent in the demo but not so in the framework.
Class loading worked fine, but an error was prompted at the following stage:
//acsCleint of initialization access
$profile = DefaultProfile: :getProfile($re gion, $accessKeyId, $accessKeySecre t);
DefaultProfile: :addEndpoint("c n-hangzhou","cn-hangzhou", $product, $domain);
Error message:
It outputs the message. The self::$endpoint s value is “null”.
The complete code of my function is as follows:
public function smsNew($data=[]){
//Replace the value here with your own AK
$accessKeyId = Config::get('al idayu.appkey');
$accessKeySecre t = Config::get('al idayu.secretKey ');
//Name of the text message API product (The text message product name is fixed and does not require modification.)
$product = "Dysmsapi";
//Domain name of the text message API product (The interface address is fixed and does not require modification.)
$domain = "dysmsapi.aliyu ncs.com";
//Multiple regions are not supported yet (Only cn-hangzhou is supported for now. Do not change it.)
$region = "cn-hangzhou";
//acsCleint of initialization access
$profile = DefaultProfile: :getProfile($re gion, $accessKeyId, $accessKeySecre t);
DefaultProfile: :addEndpoint("c n-hangzhou","cn-hangzhou", $product, $domain);
$acsClient= new DefaultAcsClien t($profile);
$request = new SendSmsRequest( );
$request->setPhoneNumber s($data['mobile']);
//Required – text message signature
$request->setSignName(Co nfig::get('alid ayu.FreeSignNam e'));
//Required – text message template code
$request->setTemplateCod e($data['template']);
//Optional – required if the template contains a variable that should be replaced (JSON format)
$request->setTemplatePar am(json_encode( $data['param']));
//Optional – Send the text message serial number
// $request->setOutId("1234 ");
//Initiate an access request
$acsResponse = $acsClient->getAcsResponse ($request);
dump($acsRespon se);
return $acsResponse;
}
My accesskey and secretKey are generated at the Access Key administration and are available.
I ran a test just now and it turned out that text message could be sent in the demo but not so in the framework.
Comment