Home > Article > Backend Development > Introduction and usage steps of Alibaba SMS service
Alibaba SMS Service: Supports high-quality capabilities such as text messages and smart pipes from the three major operators. Product features: 3 seconds reachability, 99% arrival rate, and ultra-low rates.
Steps to use Alibaba SMS service:
1. Purchase service
Go to purchase SMS service
2.Set signature file
3 .Create SMS template
4.Access Alibaba SMS service according to demo
Request parameters:
Name | Type | Must | Description |
---|---|---|---|
ParamString | STRING | Optional | Template variable, where the number must be converted to a string, the length of each variable must be less than 15 for individual users characters. For example: the SMS template is: "SMS verification code ${no}". If the parameter passed is {"no":"123456"}, the content of the text message the user will receive is: [SMS Signature] SMS Verification Code 123456 |
RecNum | STRING | Optional | Target mobile phone number, multiple records can be separated by English commas |
STRING | Optional | Signature Name | |
STRING | Optional | TemplateCODE |
<?php class Sms{public function send($ParamString,$RecNum,$SignName=’哈哈体育’,$TemplateCode=’SMS_73780003′){$host = “;;$path = “/singleSendSms”;$method = “GET”;$appcode = “这里写你的appcode “;$headers = array();array_push($headers, “Authorization:APPCODE ” . $appcode);$querys = “ParamString=”.$ParamString.”&RecNum=”.$RecNum.”&SignName=”.$SignName.”&TemplateCode=”.$TemplateCode;$bodys = “”;$url = $host . $path . “?” . $querys; $curl = curl_init();curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);curl_setopt($curl, CURLOPT_URL, $url);curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);curl_setopt($curl, CURLOPT_FAILONERROR, false);curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);curl_setopt($curl, CURLOPT_HEADER, true);if (1 == strpos(“$”.$host, “https://”)){curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);}return curl_exec($curl);} }Code explanation: $ParamString: SMS content, be sure to install your template combination In json format, for example, my SMS template is: Then my $ParamString is written as: $validate_code =mt_rand(10000,99999);//Generate a random number
$param_string =”{\”msg\”:\””.$validate_code.”\”}”;
The above is the detailed content of Introduction and usage steps of Alibaba SMS service. For more information, please follow other related articles on the PHP Chinese website!