首先下载SDK与DOME文档
http://download.csdn.net/download/weixin_40810287/10041721
里面有接口dome直接复制dome文件里的代码粘贴到你的代码上改一下引入SDK路径与个人需要修改的信息就OK!
<?php
include 'api_sdk/aliyun-php-sdk-core/Config.php';
include_once 'api_sdk/Dysmsapi/Request/V20170525/SendSmsRequest.php';
function sendSms() {
//此处需要替换成自己的AK信息
$accessKeyId = "xOSsMzW4IZ9P05cc";
$accessKeySecret = "Xdh8qqdesZ3xob94HRhSrkKctsUSgo";
//短信API产品名
$product = "Dysmsapi";
//短信API产品域名
$domain = "dysmsapi.aliyuncs.com";
//暂时不支持多Region
$region = "cn-hangzhou";
//初始化访问的acsCleint
$profile = DefaultProfile::getProfile($region, $accessKeyId, $accessKeySecret);
DefaultProfile::addEndpoint("cn-hangzhou", "cn-hangzhou", $product, $domain);
$acsClient= new DefaultAcsClient($profile);
$request = new Dysmsapi\Request\V20170525\SendSmsRequest;
//$request = new SendSmsRequest;
//必填-短信接收号码
$request->setPhoneNumbers("18336033555");
//必填-短信签名
$request->setSignName("测试签名");
//必填-短信模板Code
$request->setTemplateCode("SMS_106955001");
//选填-假如模板中存在变量需要替换则为必填(JSON格式)
$request->setTemplateParam("{\"code\":\"123456\"}");
//选填-发送短信流水号
$request->setOutId("1234");
//发起访问请求
$acsResponse = $acsClient->getAcsResponse($request);
var_dump($acsResponse);
}
sendSms();
//querySendDetails();
?>