Skip to content

Commit

Permalink
Merge pull request #106 from juvenn/feature/sms-code
Browse files Browse the repository at this point in the history
支持通用短信发送接口  close #70
  • Loading branch information
juvenn authored Sep 13, 2016
2 parents a82e7ae + 6cde297 commit 4b211be
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/LeanCloud/SMS.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace LeanCloud;

/**
* SMS
*/
class SMS {

/**
* Request SMS code
*
* Besides sending default message with sms code, you can also
* send with a customized template, which though must be submitted
* and approved before sending.
*
* The available of options are:
*
* - `$smsType` (string): "sms" or "voice"
* - `$template` (string): Template name that has been approved
* - `$name` (string): App name
* - `$ttl` (int): Number of minutes before sms code expires
* - `$op` (string): Operation name for the sms code
*
*
* @param string $phoneNumber
* @param array $options
*
* @link https://leancloud.cn/docs/rest_sms_api.html
*/
public static function requestSmsCode($phoneNumber,
$options=array()) {
forEach ($options as $k => $v) {
if (!isset($options[$k])) {
unset($options[$k]);
}
}
$options["mobilePhoneNumber"] = $phoneNumber;
Client::post("/requestSmsCode", $options);
}

/**
* Verify SMS code
*
* @param string $phoneNumber
* @param string $smsCode
*/
public static function verifySmsCode($phoneNumber, $smsCode) {
Client::post("/verifySmsCode/{$smsCode}?mobilePhoneNumber={$phoneNumber}",
null);
}

}

0 comments on commit 4b211be

Please sign in to comment.