-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from ztbcms/aliyun
新增阿里云短信服务
- Loading branch information
Showing
1,295 changed files
with
117,939 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
/** | ||
* author: Jayin <[email protected]> | ||
*/ | ||
|
||
namespace Sms\Lib\Aliyun; | ||
|
||
//引入阿里云短信服务SDK | ||
require_once(dirname(__FILE__) . '/vendor/autoload.php'); | ||
|
||
use Aliyun\Api\Sms\Request\V20170525\SendSmsRequest; | ||
use Aliyun\Core\Config; | ||
use Aliyun\Core\DefaultAcsClient; | ||
use Aliyun\Core\Profile\DefaultProfile; | ||
use Sms\Lib\BaseHelper; | ||
|
||
class Helper extends BaseHelper { | ||
|
||
/** | ||
* 短信发送 | ||
* | ||
* @param $conf array 配置 | ||
* @param $to string 短信接收人,多个接收人号码之间使用英文半角逗号隔开 | ||
* @param $param array 短信参数 | ||
* @return mixed | ||
*/ | ||
function send($conf, $to, $param) { | ||
// 加载区域结点配置 | ||
Config::load(); | ||
|
||
// 短信API产品名 | ||
$product = "Dysmsapi"; | ||
|
||
// 短信API产品域名 | ||
$domain = "dysmsapi.aliyuncs.com"; | ||
|
||
// 暂时不支持多Region | ||
$region = "cn-hangzhou"; | ||
|
||
// 服务结点 | ||
$endPointName = "cn-hangzhou"; | ||
|
||
// 初始化用户Profile实例 | ||
$profile = DefaultProfile::getProfile($region, $conf['access_id'], $conf['access_key']); | ||
|
||
// 增加服务结点 | ||
DefaultProfile::addEndpoint($endPointName, $region, $product, $domain); | ||
|
||
// 初始化AcsClient用于发起请求 | ||
$acsClient = new DefaultAcsClient($profile); | ||
|
||
// 初始化SendSmsRequest实例用于设置发送短信的参数 | ||
$request = new SendSmsRequest(); | ||
|
||
// 必填,设置雉短信接收号码 | ||
$request->setPhoneNumbers($to); | ||
|
||
// 必填,设置签名名称 | ||
$request->setSignName($conf['sign']); | ||
|
||
// 必填,设置模板CODE | ||
$request->setTemplateCode($conf['template']); | ||
|
||
// 可选,设置模板参数 | ||
if($param) { | ||
$request->setTemplateParam(json_encode($param)); | ||
} | ||
|
||
// 发起访问请求 | ||
$acsResponse = $acsClient->getAcsResponse($request); | ||
|
||
// 打印请求结果 | ||
// var_dump($acsResponse); | ||
|
||
return $acsResponse; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "aliyuncs/aliyun-dysms-php-sdk", | ||
"description": "Aliyun SMS SDK for PHP", | ||
"keywords": [ "aliyun", "SMS", "sdk" ], | ||
"type": "library", | ||
"license": "Apache-2.0", | ||
"homepage": "https://www.aliyun.com/product/sms", | ||
"authors": [ | ||
{ | ||
"name": "Aliyuncs", | ||
"homepage": "https://www.aliyun.com" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.5.0" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "~4.0" | ||
}, | ||
"minimum-stability": "stable", | ||
"autoload": { | ||
"psr-4": { | ||
"Aliyun\\": "lib/", | ||
"Aliyun\\Test\\": "tests/" | ||
} | ||
} | ||
} |
Oops, something went wrong.