Skip to content

Commit 1d8fed6

Browse files
authored
Merge pull request #131 from toplan/dev
Dev
2 parents 621ab03 + a5813da commit 1d8fed6

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

src/config/phpsms.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@
199199
'accessKeyId' => 'your_access_key_id',
200200
'accessKeySecret' => 'your_access_key_secret',
201201
'signName' => 'your_sms_sign_name',
202+
'regionId' => 'cn-shenzhen',
202203
],
203204
],
204205
];

src/phpsms/Sms.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,7 @@ protected static function modifyConfig($name, array $config, $override = false)
419419
}
420420

421421
/**
422-
* Validate the agent name.
423-
* Expected type is string, except the string of number.
422+
* Validate the name of agent.
424423
*
425424
* @param string $name
426425
*
@@ -429,7 +428,7 @@ protected static function modifyConfig($name, array $config, $override = false)
429428
protected static function validateAgentName($name)
430429
{
431430
if (empty($name) || !is_string($name) || preg_match('/^[0-9]+$/', $name)) {
432-
throw new PhpSmsException('Expected the parameter to be string which except the string of number.');
431+
throw new PhpSmsException('Expected the name of agent to be a string which except the digital string.');
433432
}
434433
}
435434

src/phpsms/agents/AliyunAgent.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@
88
* @property string $accessKeyId
99
* @property string $accessKeySecret
1010
* @property string $signName
11+
* @property string $regionId
1112
*/
1213
class AliyunAgent extends Agent implements TemplateSms
1314
{
14-
protected static $sendUrl = 'https://sms.aliyuncs.com';
15+
protected static $sendUrl = 'https://dysmsapi.aliyuncs.com/';
1516

1617
public function sendTemplateSms($to, $tempId, array $data)
1718
{
1819
$params = [
19-
'Action' => 'SingleSendSms',
20+
'Action' => 'SendSms',
2021
'SignName' => $this->signName,
21-
'ParamString' => $this->getTempDataString($data),
22-
'RecNum' => $to,
22+
'TemplateParam' => $this->getTempDataString($data),
23+
'PhoneNumbers' => $to,
2324
'TemplateCode' => $tempId,
2425
];
2526
$this->request($params);
@@ -37,8 +38,9 @@ protected function request(array $params)
3738
protected function createParams(array $params)
3839
{
3940
$params = array_merge([
41+
'RegionId' => $this->regionId ?: 'cn-shenzhen',
4042
'Format' => 'JSON',
41-
'Version' => '2016-09-27',
43+
'Version' => '2017-05-25',
4244
'AccessKeyId' => $this->accessKeyId,
4345
'SignatureMethod' => 'HMAC-SHA1',
4446
'Timestamp' => gmdate('Y-m-d\TH:i:s\Z'),
@@ -77,9 +79,8 @@ protected function setResult($result)
7779
if ($result['request']) {
7880
$this->result(Agent::INFO, $result['response']);
7981
$result = json_decode($result['response'], true);
80-
if (isset($result['Message'])) {
81-
$this->result(Agent::CODE, $result['Code']);
82-
} else {
82+
$this->result(Agent::CODE, $result['Code']);
83+
if ($result['Code'] === 'OK') {
8384
$this->result(Agent::SUCCESS, true);
8485
}
8586
} else {

src/phpsms/agents/QcloudAgent.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*
88
* @property string $appId
99
* @property string $appKey
10-
* @property string $nationCode
1110
*/
1211
class QcloudAgent extends Agent implements TemplateSms, ContentSms, VoiceCode, ContentVoice
1312
{

0 commit comments

Comments
 (0)