This is a composer/packagist fot Aliyun-Sms OpenAPI

This is a composer/packagist fot Aliyun-Sms OpenAPI

README

阿里云短信服务提供composer解决方案

install

$ composer require luyisuifeng/aliyun-php-sdk-sms

发布v1.0.1版本,修复exception命名空间问题,增加demo

#demo
use AliyunCoreProfileDefaultProfile;
use AliyunCoreDefaultAcsClient;
use AliyunCoreExceptionClientException;
use AliyunCoreExceptionServerException;
use AliyunCoreRegionsEndpoint;
use AliyunCoreRegionsEndpointProvider;
use AliyunCoreRegionsEndpointConfig;
use AliyunCoreSmsRequestV20160927SingleSendSmsRequest;
$iClientProfile = DefaultProfile::getProfile(‘cn-hangzhou’, ‘your accessKeyId’, ‘your accessSecret);
$client = new DefaultAcsClient($iClientProfile);
$config = new EndpointConfig();
$endpoint = new Endpoint(‘cn-hangzhou’, $config->getRegionIds(), $config->getProductDomains());
$endpoints = array( $endpoint );
EndpointProvider::setEndpoints($endpoints);
$request = new SingleSendSmsRequest();
$request->setSignName(‘XXXX’); //签名名称
$request->setTemplateCode(‘SMS_123456’); //模板id
$request->setRecNum(‘138xxx’);//目标手机号
$request->setParamString(“{“goodname”:”商品名”,”specinfo”:”商品属性”}”);//模板变量,数字一定要转换为字符串
try {
$response = $client->getAcsResponse($request);
print_r($response);
}
catch (ClientException $e) {
print_r($e->getErrorCode());
print_r($e->getErrorMessage());
}
catch (ServerException $e) {
print_r($e->getErrorCode());
print_r($e->getErrorMessage());
}

Source

Add a Comment

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *