Commit 1d93fb65 authored by wangzhengwen's avatar wangzhengwen

aliyunsms 入驻完善

parent 9a5afa21

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

...@@ -6,7 +6,7 @@ DEFAULT_TIMEZONE = Asia/Shanghai ...@@ -6,7 +6,7 @@ DEFAULT_TIMEZONE = Asia/Shanghai
[DATABASE] [DATABASE]
TYPE = mysql TYPE = mysql
HOSTNAME = 127.0.0.1 HOSTNAME = 192.168.4.26
DATABASE = veitooldata DATABASE = veitooldata
USERNAME = root USERNAME = root
PASSWORD = root PASSWORD = root
...@@ -16,7 +16,7 @@ CHARSET = utf8 ...@@ -16,7 +16,7 @@ CHARSET = utf8
DEBUG = true DEBUG = true
[CACHE] [CACHE]
DRIVER = file DRIVER = redis
[REDIS] [REDIS]
HOSTNAME = 127.0.0.1 HOSTNAME = 127.0.0.1
......
/.idea /.idea
/.vscode /.vscode
/nbproject /nbproject
*.log *.log
\ No newline at end of file .env
/runtime
/public
/addons
\ No newline at end of file
...@@ -8,7 +8,9 @@ use app\api\service\UserService; ...@@ -8,7 +8,9 @@ use app\api\service\UserService;
use app\api\validate\BusinessValidate; use app\api\validate\BusinessValidate;
use app\api\validate\SchoolValidate; use app\api\validate\SchoolValidate;
use app\BaseController; use app\BaseController;
use app\model\project\School;
use app\model\project\School as schoolModel; use app\model\project\School as schoolModel;
use app\model\project\Business as businessModel;
use app\model\project\User as userModel; use app\model\project\User as userModel;
use app\Request; use app\Request;
use think\facade\Cache; use think\facade\Cache;
...@@ -30,7 +32,7 @@ class Settled extends BaseController ...@@ -30,7 +32,7 @@ class Settled extends BaseController
{ {
$vo = (new SchoolValidate())->goCheck(); $vo = (new SchoolValidate())->goCheck();
if ($vo !== true) { if ($vo !== true) {
// return $vo; return $vo;
} }
$data = $request->param(); $data = $request->param();
...@@ -61,12 +63,80 @@ class Settled extends BaseController ...@@ -61,12 +63,80 @@ class Settled extends BaseController
/**企业 /**企业
* *
*/ */
public function business() public function business(Request $request)
{ {
$vo = (new BusinessValidate())->goCheck(); $vo = (new BusinessValidate())->goCheck();
if ($vo !== true) { if ($vo !== true) {
return $vo; return $vo;
} }
$data = $request->param();
$token = $request->header('token');
$user = UserService::getUserInfo($token);
if (!$user)
{
return $this->returnMsg('token无效',0);
}
if (businessModel::where('user_id', $user['id'])->count())
{
return $this->returnMsg('请勿重复提交',0);
}
$data['user_id'] = $user['id'];
businessModel::create($data);
userModel::where('id',$user['id'])->update(['role'=>2]);
return $this->returnMsg('操作成功',1);
}
public function getSchoolData(Request $request)
{
$vo = (new BusinessValidate())->goCheck(['token']);
if ($vo !== true) {
return $vo;
}
$token = $request->header('token');
$user = UserService::getUserInfo($token);
if (!$user)
{
return $this->returnMsg('token无效',0);
}
$data = schoolModel::where(['user_id'=>$user['id']])
->with(['schoolQualification','teacherQualification','agreement','moreFile'])
->find();
return $this->returnMsg('操作成功',1,$data);
} }
public function getBusinessData(Request $request)
{
$vo = (new BusinessValidate())->goCheck(['token']);
if ($vo !== true) {
return $vo;
}
$token = $request->header('token');
$user = UserService::getUserInfo($token);
if (!$user)
{
return $this->returnMsg('token无效',0);
}
$data = businessModel::where(['user_id'=>$user['id']])
->with(['businessQualification','businessIndustry','businessPorject','businessMore','businessLogo'])
->find();
return $this->returnMsg('操作成功',1,$data);
}
} }
\ No newline at end of file
...@@ -2,9 +2,29 @@ ...@@ -2,9 +2,29 @@
namespace app\api\controller; namespace app\api\controller;
use app\api\validate\UserValidate;
use app\BaseController; use app\BaseController;
use app\Request;
use tool\SendSms;
class Sms extends BaseController class Sms extends BaseController
{ {
public function sendSms(Request $request)
{
$vo = (new UserValidate())->goCheck(['mobile']);
if ($vo !== true) {
return $vo;
}
$data = $request->param();
$code = str_pad(random_int(0, 9999), 4, '0', STR_PAD_LEFT);
// halt($code);
$SMS = new SendSms();
return $this->returnMsg($SMS->aliyun_send($data['mobile'], $code));
}
} }
\ No newline at end of file
<?php
namespace app\api\controller;
use app\BaseController;
use app\model\project\AdvertCate;
class System extends BaseController
{
/**
* 轮播图列表
*/
public function getBannerList()
{
$list = AdvertCate::where(['position'=>1,'is_show'=>1])
->with(['getAdvertList'=>['coverImg']])
->find()
->toArray();
return $this->returnMsg('操作成功',1,$list);
}
}
\ No newline at end of file
...@@ -2,12 +2,19 @@ ...@@ -2,12 +2,19 @@
namespace app\api\controller; namespace app\api\controller;
use app\api\middleware\Auth;
use app\BaseController; use app\BaseController;
use app\model\system\SystemArea; use app\model\system\SystemArea;
class Util extends BaseController class Util extends BaseController
{ {
protected $middleware = [
[
'Auth' => ['except' => ['sums']]
],
];
public function getAreaJson() public function getAreaJson()
{ {
return $this->returnMsg('操作成功',1,SystemArea::getAreaJson()); return $this->returnMsg('操作成功',1,SystemArea::getAreaJson());
......
...@@ -19,8 +19,8 @@ class UserService ...@@ -19,8 +19,8 @@ class UserService
} }
$user = userModel::where(['token'=>$token]) $user = userModel::where(['token'=>$token])
->field('id,username,mobile,realname,token') ->field('id,username,mobile,realname,token,role')
->with(['getSchoolData','getBusinessData']) // ->with(['getSchoolData','getBusinessData'=>['businessQualification']])
->find(); ->find();
if (!$user) if (!$user)
{ {
......
...@@ -5,6 +5,7 @@ namespace app\api\validate; ...@@ -5,6 +5,7 @@ namespace app\api\validate;
class BusinessValidate extends BaseValidate class BusinessValidate extends BaseValidate
{ {
protected $rule = [ protected $rule = [
'token'=>'require',
'name' => 'require', 'name' => 'require',
'type' => 'require', 'type' => 'require',
'scale'=>'require', 'scale'=>'require',
......
...@@ -5,6 +5,7 @@ namespace app\api\validate; ...@@ -5,6 +5,7 @@ namespace app\api\validate;
class SchoolValidate extends BaseValidate class SchoolValidate extends BaseValidate
{ {
protected $rule = [ protected $rule = [
'token'=>'require',
'name' => 'require', 'name' => 'require',
'type' => 'require', 'type' => 'require',
'province'=>'require', 'province'=>'require',
......
<?php
namespace app\model\project;
use app\model\system\SystemUploadFile;
use think\Model;
class Advert extends Model
{
protected $name = 'advert';
protected $autoWriteTimestamp = true;
protected $createTime = 'create_time';
public function coverImg()
{
return $this->hasOne(SystemUploadFile::class, 'fileid', 'cover_img_id')
->field('fileid, filename, filesize, fileurl, filetype');
}
}
\ No newline at end of file
<?php
namespace app\model\project;
use think\Model;
class AdvertCate extends Model
{
protected $name = 'advert_cate';
protected $autoWriteTimestamp = true;
protected $createTime = 'create_time';
public function getAdvertList()
{
return $this->hasMany(Advert::class, 'p_id', 'id')
->field('id,name,type,url,p_id,url,cover_img_id')
->order('sort desc');
}
}
\ No newline at end of file
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace app\model\project; namespace app\model\project;
use app\model\system\SystemUploadFile;
use think\Model; use think\Model;
class Business extends Model class Business extends Model
...@@ -11,4 +12,39 @@ class Business extends Model ...@@ -11,4 +12,39 @@ class Business extends Model
protected $autoWriteTimestamp = true; protected $autoWriteTimestamp = true;
protected $createTime = 'create_time'; protected $createTime = 'create_time';
// 营业执照文件关联
public function businessQualification()
{
return $this->hasOne(SystemUploadFile::class, 'fileid', 'business_qualification_url_id')
->field('fileid,filename,filesize,fileurl,filetype');
}
//行业
public function businessIndustry()
{
return $this->hasOne(SystemUploadFile::class, 'fileid', 'business_industry_url_id')
->field('fileid,filename,filesize,fileurl,filetype');
}
//项目
public function businessPorject()
{
return $this->hasOne(SystemUploadFile::class, 'fileid', 'business_project_url_id')
->field('fileid,filename,filesize,fileurl,filetype');
}
//补充材料
public function businessMore()
{
return $this->hasOne(SystemUploadFile::class, 'fileid', 'more_url_id')
->field('fileid,filename,filesize,fileurl,filetype');
}
//企业logo
public function businessLogo()
{
return $this->hasOne(SystemUploadFile::class, 'fileid', 'business_logo_url_id')
->field('fileid,filename,filesize,fileurl,filetype');
}
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace app\model\project; namespace app\model\project;
use app\model\system\SystemUploadFile;
use think\Model; use think\Model;
class School extends Model class School extends Model
...@@ -11,4 +12,32 @@ class School extends Model ...@@ -11,4 +12,32 @@ class School extends Model
protected $autoWriteTimestamp = true; protected $autoWriteTimestamp = true;
protected $createTime = 'create_time'; protected $createTime = 'create_time';
//学校资质id
public function schoolQualification()
{
return $this->hasOne(SystemUploadFile::class, 'fileid', 'school_qualification_url_id')
->field('fileid,filename,filesize,fileurl,filetype');
}
//导师资质
public function teacherQualification()
{
return $this->hasOne(SystemUploadFile::class, 'fileid', 'teacher_qualification_url_id')
->field('fileid, filename, filesize, fileurl, filetype');
}
//合作协议
public function agreement()
{
return $this->hasOne(SystemUploadFile::class, 'fileid', 'agreement_url_id')
->field('fileid, filename, filesize, fileurl, filetype');
}
//补充材料
public function moreFile()
{
return $this->hasOne(SystemUploadFile::class, 'fileid', 'more_url_id')
->field('fileid, filename, filesize, fileurl, filetype');
}
} }
\ No newline at end of file
...@@ -25,4 +25,5 @@ class User extends Model ...@@ -25,4 +25,5 @@ class User extends Model
return $this->hasOne(Business::class, 'user_id', 'id'); return $this->hasOne(Business::class, 'user_id', 'id');
} }
} }
\ No newline at end of file
This diff is collapsed.
...@@ -9,7 +9,11 @@ ...@@ -9,7 +9,11 @@
*/ */
namespace tool; namespace tool;
use think\facade\Db; use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;
use AlibabaCloud\Dysmsapi\Dysmsapi;
use think\Facade\Db;
/** /**
* 短信发送类 * 短信发送类
...@@ -167,4 +171,91 @@ class SendSms ...@@ -167,4 +171,91 @@ class SendSms
return ['msg'=>$txt,'code'=>($key==0 ? 1 : 0)]; return ['msg'=>$txt,'code'=>($key==0 ? 1 : 0)];
} }
/**
* 短信宝发送短信
* @access public
* @param string $mobile 手机号
* @param string $message 短信内容
* @param int $word 发送的字数
* @param int $lent 间隔时间(秒)
* @return array
*/
public function aliyun_send(int $mobile = 0, int $code = 0, int $tpid = 0, string $tips = '', int $lent = 0)
{
$errMsg = '';
$time = time();
$res_code = 0;
$status = 1;
//屏蔽频繁发送
$arr = cache($this->cache_key);
$lent = $lent ? $lent : vconfig('sms_times');
if(isset($arr['time']) && ($time-$arr['time'])<$lent) return ['msg'=>'发送过于频繁!','code'=>0];
//整合配置
$this->config = array_merge($this->config, vconfig());
if(!$this->config['sms_state']) return ['msg'=>'短信接口未开启','code'=>0];
if(!$mobile) return ['msg'=>'手机号不能为空','code'=>0];
if(!$code) return ['msg'=>'短信验证码不能为空','code'=>0];
$template_id = $tpid ? $tpid : $this->config['sms_template_id'];
AlibabaCloud::accessKeyClient($this->config['AccessKeyID'], $this->config['AccessKeySecret'])
->regionId('cn-hangzhou')
->asDefaultClient();
try {
// 2. 创建请求对象
$result = AlibabaCloud::rpc()
->product('Dysmsapi') // 指定产品
->version('2017-05-25') // 指定API版本
->action('SendSms') // 指定接口动作
->method('POST') // 请求方法
->host('dysmsapi.aliyuncs.com') // 服务地址
->options([
'query' => [
'PhoneNumbers' => $mobile, // 手机号
'SignName' => '重庆流速科技', // 短信签名
'TemplateCode' => $template_id, // 短信模板CODE
'TemplateParam' => json_encode([ // 模板参数(JSON格式)
'code' => $code,
// 'time' => '5分钟'
]),
// 'OutId' => 'your_out_id', // 可选:外部流水号(用于回调识别)
// 'SmsUpExtendCode' => '123', // 可选:上行短信扩展码
],
])
->connectTimeout(10) // 连接超时(秒)
->timeout(10) // 请求超时(秒)
->request(); // 执行请求
$res_code = 200;
$errMsg = 'success';
$status = 1;
cache($this->cache_key,['time'=>$time]);
} catch (ClientException $e) {
$res_code = $e->getCode();
$errMsg = $e->getMessage();
$this->clear_time_cache();
} catch (ServerException $e) {
$res_code = $e->getCode();
$errMsg = $e->getMessage();
$this->clear_time_cache();
}
$message = '您的验证码为:'.$code.',请勿泄露于他人!';
$word = function_exists('mb_strlen') ? mb_strlen($message,'utf8') : 0;
$data = ['mobile'=> $mobile,'message'=>$message,'word'=>$word,
'editor'=>'api','sendtime'=>$time,'code'=>$code,
'err_msg'=>$errMsg,'res_code'=>$res_code,'status'=>$status,];
Db::name('system_sms')->data($data)->insert();
return ['res_code'=>$res_code,'status'=>$status];
}
} }
\ No newline at end of file
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php$1 last;
}
\ No newline at end of file
# The MIT License (MIT)
Copyright (c) 2016-2019 Riku Särkinen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
{
"name": "adbario/php-dot-notation",
"description": "PHP dot notation access to arrays",
"keywords": ["dotnotation", "arrayaccess"],
"homepage": "https://github.com/adbario/php-dot-notation",
"license": "MIT",
"authors": [
{
"name": "Riku Särkinen",
"email": "riku@adbar.io"
}
],
"require": {
"php": "^5.5 || ^7.0 || ^8.0",
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": "^4.8|^5.7|^6.6|^7.5|^8.5|^9.5",
"squizlabs/php_codesniffer": "^3.6"
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Adbar\\": "src"
}
}
}
This diff is collapsed.
<?php
/**
* Dot - PHP dot notation access to arrays
*
* @author Riku Särkinen <riku@adbar.io>
* @link https://github.com/adbario/php-dot-notation
* @license https://github.com/adbario/php-dot-notation/blob/2.x/LICENSE.md (MIT License)
*/
use Adbar\Dot;
if (! function_exists('dot')) {
/**
* Create a new Dot object with the given items and optional delimiter
*
* @param mixed $items
* @param string $delimiter
* @return \Adbar\Dot
*/
function dot($items, $delimiter = '.')
{
return new Dot($items, $delimiter);
}
}
# CHANGELOG
## 1.5.32 - 2022-12-08
- Support PHP versions: From 5.5 up to 8.1
## 1.5.31 - 2021-05-13
- Deprecate `\GuzzleHttp\Psr7\parse_query` method
## 1.5.30 - 2021-03-22
- Fixed incompatibility in PHP 5.6 version.
## 1.5.29 - 2020-08-03
- Fixed RPC Signature.
## 1.5.28 - 2020-08-03
- Updated `endpoints`.
## 1.5.27 - 2020-07-17
- Fixed composer error config.
## 1.5.26 - 2020-07-17
- Validate RegionID/EndpointSuffix/Network.
## 1.5.25 - 2020-07-04
- Fixed ROA signature.
- Deprecated `LogFormatter`.
## 1.5.24 - 2020-06-04
- Fixed Resolve Host.
## 1.5.23 - 2020-05-22
- Optimized global product support.
## 1.5.22 - 2020-05-12
- Updated Endpoints.
## 1.5.21 - 2020-02-26
- Improved Nonce.
- Updated Endpoints.
## 1.5.20 - 2019-12-30
- Improved Docs.
- Updated Endpoints.
## 1.5.19 - 2019-12-17
- Updated Endpoints.
## 1.5.18 - 2019-10-11
- Updated Request link.
- Updated Endpoints data.
## 1.5.17 - 2019-09-15
- Improved Host Finder.
- Updated Endpoints Data.
## 1.5.16 - 2019-08-21
- Updated Endpoints Data.
## 1.5.15 - 2019-08-14
- Improved Client.
## 1.5.14 - 2019-07-25
- Improved Credential Filter.
## 1.5.13 - 2019-07-18
- Improved API Resolver.
## 1.5.12 - 2019-06-20
- Fixed Signature for ROA.
## 1.5.11 - 2019-06-14
- Added endpoint rules.
## 1.5.10 - 2019-06-13
- Improved `Resovler`.
- Updated `endpoints`.
## 1.5.9 - 2019-06-04
- Improved `UUID`.
## 1.5.8 - 2019-05-30
- Improved `Arrays`.
## 1.5.7 - 2019-05-29
- Improved `uuid`.
## 1.5.6 - 2019-05-29
- Fixed `uuid` version lock.
## 1.5.5 - 2019-05-23
- Improved `Signature`.
## 1.5.4 - 2019-05-22
- Updated `Endpoints`.
- Fixed `Content-Type` in header.
## 1.5.3 - 2019-05-13
- Improved `Endpoint` tips.
- Improved `Endpoints` for `STS`.
## 1.5.2 - 2019-05-10
- Improved `Result` object.
## 1.5.1 - 2019-05-09
- Supported `Resolver` for Third-party dependencies.
## 1.5.0 - 2019-05-07
- Improved `Resolver` for products.
## 1.4.0 - 2019-05-06
- Support `Retry` and `Asynchronous` for Request.
## 1.3.1 - 2019-04-30
- Allow timeouts to be set in microseconds.
## 1.3.0 - 2019-04-18
- Improved parameters methods.
- Optimized the logic for body encode.
## 1.2.1 - 2019-04-11
- Improve exception code and message for `Region ID`.
## 1.2.0 - 2019-04-11
- Improve exception message for `Region ID`.
## 1.1.1 - 2019-04-02
- Added endpoints for `batchcomputenew`, `privatelink`.
- Improve Region ID tips.
## 1.1.0 - 2019-04-01
- Updated `composer.json`.
## 1.0.27 - 2019-03-31
- Support `Policy` for `ramRoleArnClient`.
## 1.0.26 - 2019-03-27
- Support `pid`, `cost`, `start_time` for Log.
## 1.0.25 - 2019-03-27
- Updated default log format.
- Add endpoints for `dbs`.
## 1.0.24 - 2019-03-26
- Support Log.
## 1.0.23 - 2019-03-23
- Remove SVG.
## 1.0.22 - 2019-03-20
- Add endpoint `cn-hangzhou` for `idaas` .
## 1.0.21 - 2019-03-19
- Installing by Using the ZIP file.
- Update Docs.
## 1.0.20 - 2019-03-13
- Improve Tests.
- Update Docs.
## 1.0.19 - 2019-03-12
- Add SSL Verify Option `verify()`.
## 1.0.18 - 2019-03-11
- Add endpoints for `acr`.
- Add endpoints for `faas`.
- Add endpoints for `ehs`.
- SSL certificates are not validated by default.
## 1.0.17 - 2019-03-08
- Support Mock for Test.
## 1.0.16 - 2019-03-07
- Support Credential Provider Chain.
- Support `CCC`.
- Add `ap-south-1` for `cas`.
- Add `ap-southeast-1` for `waf`.
- Update Docs.
## 1.0.15 - 2019-02-27
- Add endpoints for `Chatbot`.
- Change endpoints for `drdspost` and `drdspre`.
## 1.0.14 - 2019-02-21
- Enable debug mode by set environment variable `DEBUG=sdk`.
## 1.0.13 - 2019-02-18
- Support Release Script `composer release`.
- Add endpoints for apigateway in `drdspre` in `cn-qingdao`.
- Add endpoints for apigateway in `drdspre` in `cn-beijing`.
- Add endpoints for apigateway in `drdspre` in `cn-hangzhou`.
- Add endpoints for apigateway in `drdspre` in `cn-shanghai`.
- Add endpoints for apigateway in `drdspre` in `cn-shenzhen`.
- Add endpoints for apigateway in `drdspre` in `cn-hongkong`.
- Add endpoints for apigateway in `drdspost` in `ap-southeast-1`.
- Add endpoints for apigateway in `drdspost` in `cn-shanghai`.
- Add endpoints for apigateway in `drdspost` in `cn-hongkong`.
- Add endpoints for apigateway in `vod` in `ap-southeast-1`.
- Add endpoints for apigateway in `vod` in `eu-central-1`.
## 1.0.12 - 2019-02-16
- Support `open_basedir`.
## 1.0.11 - 2019-02-13
- Improve User Agent.
## 1.0.10 - 2019-02-12
- `userAgentAppend` is renamed to `appendUserAgent`.
## 1.0.9 - 2019-02-12
- `userAgent` is renamed to `userAgentAppend`.
## 1.0.8 - 2019-02-11
- `userAgent` - Support DIY User Agent.
- Add endpoints for apigateway in Zhangjiakou.
- Add endpoints for apigateway in Hu He Hao Te.
- Add endpoints for vod in Hu He Hao Te.
- Add endpoints for hsm in Zhangjiakou.
- Add endpoints for luban in Germany.
- Add endpoints for linkwan in Hangzhou.
- Add endpoints for drdspost in Singapore.
## 1.0.7 - 2019-01-28
- Add endpoints for gpdb in Tokyo.
- Add endpoints for elasticsearch in Beijing.
## 1.0.6 - 2019-01-23
- Add endpoints for dysmsapi in Singapore.
- Add endpoints for dybaseapi.
- Add endpoints for dyiotapi.
- Add endpoints for dycdpapi.
- Add endpoints for dyplsapi.
- Add endpoints for dypnsapi.
- Add endpoints for dyvmsapi.
- Add endpoints for snsuapi.
## 1.0.5 - 2019-01-21
- Add endpoints for ApiGateway in Silicon Valley, Virginia.
- Add endpoints for Image Search in Shanghai.
## 1.0.4 - 2019-01-17
- Support fixer all.
- Add Endpoints.
## 1.0.3 - 2019-01-15
- Update Endpoints.
- Update README.md.
- Update Return Result Message.
## 1.0.2 - 2019-01-15
- Optimize the documentation.
- Adjust the CI configuration.
## 1.0.1 - 2019-01-09
- Distinguish credential error.
- Add endpoints for NLS.
- Add not found product tip.
## 1.0.0 - 2019-01-07
- Initial release of the Alibaba Cloud Client for PHP Version 1.0.0 on Packagist See <https://github.com/aliyun/openapi-sdk-php-client> for more information.
# Contributing to the Alibaba Cloud Client for PHP
We work hard to provide a high-quality and useful SDK for Alibaba Cloud, and
we greatly value feedback and contributions from our community. Please submit
your [issues][issues] or [pull requests][pull-requests] through GitHub.
## Tips
- The SDK is released under the [Apache license][license]. Any code you submit
will be released under that license. For substantial contributions, we may
ask you to sign a [Alibaba Documentation Corporate Contributor License
Agreement (CLA)][cla].
- We follow all of the relevant PSR recommendations from the [PHP Framework
Interop Group][php-fig]. Please submit code that follows these standards.
The [PHP CS Fixer][cs-fixer] tool can be helpful for formatting your code.
Your can use `composer fixer` to fix code.
- We maintain a high percentage of code coverage in our unit tests. If you make
changes to the code, please add, update, and/or remove tests as appropriate.
- If your code does not conform to the PSR standards, does not include adequate
tests, or does not contain a changelog document, we may ask you to update
your pull requests before we accept them. We also reserve the right to deny
any pull requests that do not align with our standards or goals.
[issues]: https://github.com/aliyun/openapi-sdk-php-client/issues
[pull-requests]: https://github.com/aliyun/openapi-sdk-php-client/pulls
[license]: http://www.apache.org/licenses/LICENSE-2.0
[cla]: https://alibaba-cla-2018.oss-cn-beijing.aliyuncs.com/Alibaba_Documentation_Open_Source_Corporate_CLA.pdf
[php-fig]: http://php-fig.org
[cs-fixer]: http://cs.sensiolabs.org/
[docs-readme]: https://github.com/aliyun/openapi-sdk-php-client/blob/master/README.md
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
Licensed 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.
# Alibaba Cloud Client for PHP
<https://www.alibabacloud.com/>
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License").
You may not use this file except in compliance with the License.
A copy of the License is located at
<http://www.apache.org/licenses/LICENSE-2.0>
or in the "license" file accompanying this file. This file 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.
# Guzzle
<https://github.com/guzzle/guzzle>
Copyright (c) 2011-2018 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
# jmespath.php
<https://github.com/mtdowling/jmespath.php>
Copyright (c) 2014 Michael Dowling, https://github.com/mtdowling
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
# Dot
<https://github.com/adbario/php-dot-notation>
Copyright (c) 2016-2019 Riku Särkinen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
[English](/README.md) | 简体中文
# Alibaba Cloud Client for PHP
[![Latest Stable Version](https://poser.pugx.org/alibabacloud/client/v/stable)](https://packagist.org/packages/alibabacloud/client)
[![composer.lock](https://poser.pugx.org/alibabacloud/client/composerlock)](https://packagist.org/packages/alibabacloud/client)
[![Total Downloads](https://poser.pugx.org/alibabacloud/client/downloads)](https://packagist.org/packages/alibabacloud/client)
[![License](https://poser.pugx.org/alibabacloud/client/license)](https://packagist.org/packages/alibabacloud/client)
[![codecov](https://codecov.io/gh/aliyun/openapi-sdk-php-client/branch/master/graph/badge.svg?token=90Yd5Bne3S)](https://codecov.io/gh/aliyun/openapi-sdk-php-client)
[![PHP Version Require](http://poser.pugx.org/alibabacloud/client/require/php)](https://packagist.org/packages/alibabacloud/client)
![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg)
Alibaba Cloud Client for PHP 是帮助 PHP 开发者管理凭据、发送请求的客户端工具,[Alibaba Cloud SDK for PHP][SDK] 由本工具提供底层支持。
## 使用诊断
[Troubleshoot](https://troubleshoot.api.aliyun.com/?source=github_sdk) 提供 OpenAPI 使用诊断服务,通过 `RequestID``报错信息` ,帮助开发者快速定位,为开发者提供解决方案。
## 在线示例
[阿里云 OpenAPI 开发者门户]https://next.api.aliyun.com/) 提供在线调用阿里云产品,并动态生成 SDK 代码和快速检索接口等能力,能显著降低使用云 API 的难度。
## 先决条件
您的系统需要满足[先决条件](/docs/zh-CN/0-Prerequisites.md),包括 PHP> = 5.5。 我们强烈建议使用cURL扩展,并使用TLS后端编译cURL 7.16.2+。
## 安装依赖
如果已在系统上[全局安装 Composer](https://getcomposer.org/doc/00-intro.md#globally),请直接在项目目录中运行以下内容来安装 Alibaba Cloud Client for PHP 作为依赖项:
```
composer require alibabacloud/client
```
> 一些用户可能由于网络问题无法安装,可以使用[阿里云 Composer 全量镜像](https://developer.aliyun.com/composer)。
请看[安装](/docs/zh-CN/1-Installation.md)有关通过 Composer 和其他方式安装的详细信息。
## 快速使用
在您开始之前,您需要注册阿里云帐户并获取您的[凭证](https://usercenter.console.aliyun.com/#/manage/ak)
```php
<?php
use AlibabaCloud\Client\AlibabaCloud;
AlibabaCloud::accessKeyClient('accessKeyId', 'accessKeySecret')->asDefaultClient();
```
## 请求
> 请求风格分为 `ROA` 和 `RPC`,不同产品风格不同,使用前,请参考产品文档。推荐使用 [Alibaba Cloud SDK for PHP][SDK] ,细节已被封装,无需关心风格。
### ROA 请求
```php
<?php
use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;
try {
$result = AlibabaCloud::roa()
->regionId('cn-hangzhou') // 指定请求的区域,不指定则使用客户端区域、默认区域
->product('CS') // 指定产品
->version('2015-12-15') // 指定产品版本
->action('DescribeClusterServices') // 指定产品接口
->serviceCode('cs') // 设置 ServiceCode 以备寻址,非必须
->endpointType('openAPI') // 设置类型,非必须
->method('GET') // 指定请求方式
->host('cs.aliyun.com') // 指定域名则不会寻址,如认证方式为 Bearer Token 的服务则需要指定
->pathPattern('/clusters/[ClusterId]/services') // 指定ROA风格路径规则
->withClusterId('123456') // 为路径中参数赋值,方法名:with + 参数
->request(); // 发起请求并返回结果对象,请求需要放在设置的最后面
print_r($result->toArray());
} catch (ClientException $exception) {
print_r($exception->getErrorMessage());
} catch (ServerException $exception) {
print_r($exception->getErrorMessage());
}
```
### RPC 请求
```php
<?php
use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;
try {
$result = AlibabaCloud::rpc()
->product('Cdn')
->version('2014-11-11')
->action('DescribeCdnService')
->method('POST')
->request();
print_r($result->toArray());
} catch (ClientException $exception) {
print_r($exception->getErrorMessage());
} catch (ServerException $exception) {
print_r($exception->getErrorMessage());
}
```
## 文档
* [先决条件](/docs/zh-CN/0-Prerequisites.md)
* [安装](/docs/zh-CN/1-Installation.md)
* [客户端和凭证](/docs/zh-CN/2-Client.md)
* [请求](/docs/zh-CN/3-Request.md)
* [结果](/docs/zh-CN/4-Result.md)
* [区域](/docs/zh-CN/5-Region.md)
* [域名](/docs/zh-CN/6-Host.md)
* [SSL 验证](/docs/zh-CN/7-Verify.md)
* [调试](/docs/zh-CN/8-Debug.md)
* [日志](/docs/zh-CN/9-Log.md)
* [测试](/docs/zh-CN/10-Test.md)
## 问题
[提交 Issue](https://github.com/aliyun/openapi-sdk-php-client/issues/new/choose),不符合指南的问题可能会立即关闭。
## 发行说明
每个版本的详细更改记录在[发行说明](/CHANGELOG.md)中。
## 贡献
提交 Pull Request 之前请阅读[贡献指南](/CONTRIBUTING.md)
## 相关
* [阿里云服务 Regions & Endpoints][endpoints]
* [阿里云 OpenAPI 开发者门户][open-api]
* [Packagist][packagist]
* [Composer][composer]
* [Guzzle中文文档][guzzle-docs]
* [最新源码][latest-release]
## 许可证
[Apache-2.0](/LICENSE.md)
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
[SDK]: https://github.com/aliyun/openapi-sdk-php
[open-api]: https://next.api.aliyun.com/
[latest-release]: https://github.com/aliyun/openapi-sdk-php-client
[guzzle-docs]: https://guzzle-cn.readthedocs.io/zh_CN/latest/request-options.html
[composer]: https://getcomposer.org
[packagist]: https://packagist.org/packages/alibabacloud/sdk
[home]: https://home.console.aliyun.com
[aliyun]: https://www.aliyun.com
[regions]: https://help.aliyun.com/document_detail/40654.html
[endpoints]: https://developer.aliyun.com/endpoints
[cURL]: http://php.net/manual/zh/book.curl.php
[OPCache]: http://php.net/manual/zh/book.opcache.php
[xdebug]: http://xdebug.org
[OpenSSL]: http://php.net/manual/zh/book.openssl.php
[client]: https://github.com/aliyun/openapi-sdk-php-client
English | [简体中文](/README-zh-CN.md)
# Alibaba Cloud Client for PHP
[![Latest Stable Version](https://poser.pugx.org/alibabacloud/client/v/stable)](https://packagist.org/packages/alibabacloud/client)
[![composer.lock](https://poser.pugx.org/alibabacloud/client/composerlock)](https://packagist.org/packages/alibabacloud/client)
[![Total Downloads](https://poser.pugx.org/alibabacloud/client/downloads)](https://packagist.org/packages/alibabacloud/client)
[![License](https://poser.pugx.org/alibabacloud/client/license)](https://packagist.org/packages/alibabacloud/client)
[![codecov](https://codecov.io/gh/aliyun/openapi-sdk-php-client/branch/master/graph/badge.svg?token=90Yd5Bne3S)](https://codecov.io/gh/aliyun/openapi-sdk-php-client)
[![PHP Version Require](http://poser.pugx.org/alibabacloud/client/require/php)](https://packagist.org/packages/alibabacloud/client)
![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg)
Alibaba Cloud Client for PHP is a client tool that helps PHP developers manage credentials and send requests, [Alibaba Cloud SDK for PHP][SDK] dependency on this tool.
## Troubleshoot
[Troubleshoot](https://troubleshoot.api.aliyun.com/?source=github_sdk) Provide OpenAPI diagnosis service to help developers locate quickly and provide solutions for developers through `RequestID` or `error message`.
## Online Demo
[Alibaba Cloud OpenAPI Developer Portal](https://next.api.aliyun.com/) provides the ability to call the cloud product OpenAPI online, and dynamically generate SDK Example code and quick retrieval interface, which can significantly reduce the difficulty of using the cloud API.
## Prerequisites
Your system will need to meet the [Prerequisites](/docs/en-US/0-Prerequisites.md), including having PHP >= 5.5. We highly recommend having it compiled with the cURL extension and cURL 7.16.2+.
## Installation
If Composer is already [installed globally on your system](https://getcomposer.org/doc/00-intro.md#globally), run the following in the base directory of your project to install Alibaba Cloud Client for PHP as a dependency:
```
composer require alibabacloud/client
```
> Some users may not be able to install due to network problems, you can try to switch the Composer mirror.
Please see the [Installation](/docs/en-US/1-Installation.md) for more detailed information about installing the Alibaba Cloud Client for PHP through Composer and other means.
## Quick Examples
Before you begin, you need to sign up for an Alibaba Cloud account and retrieve your [Credentials](https://usercenter.console.aliyun.com/#/manage/ak).
### Create Client
```php
<?php
use AlibabaCloud\Client\AlibabaCloud;
AlibabaCloud::accessKeyClient('accessKeyId', 'accessKeySecret')->asDefaultClient();
```
## Request
> Request styles are divided into `ROA` and `RPC`. Different product styles are different. Please refer to the product documentation before using. It is recommended to use [Alibaba cloud SDK for PHP][SDK], the details have been encapsulated, and you do not need to care about the style.
### ROA Request
```php
<?php
use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;
try {
$result = AlibabaCloud::roa()
->regionId('cn-hangzhou') // Specify the requested regionId, if not specified, use the client regionId, then default regionId
->product('CS') // Specify product
->version('2015-12-15') // Specify product version
->action('DescribeClusterServices') // Specify product interface
->serviceCode('cs') // Set ServiceCode for addressing, optional
->endpointType('openAPI') // Set type, optional
->method('GET') // Set request method
->host('cs.aliyun.com') // Location Service will not be enabled if the host is specified. For example, service with a Certification type-Bearer Token should be specified
->pathPattern('/clusters/[ClusterId]/services') // Specify path rule with ROA-style
->withClusterId('123456') // Assign values to parameters in the path. Method: with + Parameter
->request(); // Make a request and return to result object. The request is to be placed at the end of the setting
print_r($result->toArray());
} catch (ClientException $exception) {
print_r($exception->getErrorMessage());
} catch (ServerException $exception) {
print_r($exception->getErrorMessage());
}
```
### RPC Request
```php
<?php
use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;
try {
$result = AlibabaCloud::rpc()
->product('Cdn')
->version('2014-11-11')
->action('DescribeCdnService')
->method('POST')
->request();
print_r($result->toArray());
} catch (ClientException $exception) {
print_r($exception->getErrorMessage());
} catch (ServerException $exception) {
print_r($exception->getErrorMessage());
}
```
## Documentation
* [Prerequisites](/docs/en-US/0-Prerequisites.md)
* [Installation](/docs/en-US/1-Installation.md)
* [Client & Credentials](/docs/en-US/2-Client.md)
* [Request](/docs/en-US/3-Request.md)
* [Result](/docs/en-US/4-Result.md)
* [Region](/docs/en-US/5-Region.md)
* [Host](/docs/en-US/6-Host.md)
* [SSL Verify](/docs/en-US/7-Verify.md)
* [Debug](/docs/en-US/8-Debug.md)
* [Log](/docs/en-US/9-Log.md)
* [Test](/docs/en-US/10-Test.md)
## Issues
[Opening an Issue](https://github.com/aliyun/openapi-sdk-php-client/issues/new/choose), Issues not conforming to the guidelines may be closed immediately.
## Changelog
Detailed changes for each release are documented in the [release notes](/CHANGELOG.md).
## Contribution
Please make sure to read the [Contributing Guide](/CONTRIBUTING.md) before making a pull request.
## References
* [Alibaba Cloud Regions & Endpoints][endpoints]
* [Alibaba Cloud OpenAPI Developer Portal][open-api]
* [Packagist][packagist]
* [Composer][composer]
* [Guzzle Documentation][guzzle-docs]
* [Latest Release][latest-release]
## License
[Apache-2.0](/LICENSE.md)
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
[SDK]: https://github.com/aliyun/openapi-sdk-php
[open-api]: https://next.api.aliyun.com/
[latest-release]: https://github.com/aliyun/openapi-sdk-php-client
[guzzle-docs]: http://docs.guzzlephp.org/en/stable/request-options.html
[composer]: https://getcomposer.org
[packagist]: https://packagist.org/packages/alibabacloud/sdk
[home]: https://home.console.aliyun.com
[alibabacloud]: https://www.alibabacloud.com
[regions]: https://www.alibabacloud.com/help/doc-detail/40654.html
[endpoints]: https://developer.aliyun.com/endpoints
[cURL]: http://php.net/manual/en/book.curl.php
[OPCache]: http://php.net/manual/en/book.opcache.php
[xdebug]: http://xdebug.org
[OpenSSL]: http://php.net/manual/en/book.openssl.php
[client]: https://github.com/aliyun/openapi-sdk-php-client
Upgrading Guide
===============
1.x
-----------------------
- This is the first version. See <https://github.com/aliyun/openapi-sdk-php-client> for more information.
<?php
if (\file_exists(__DIR__ . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php')) {
require_once __DIR__ . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
}
spl_autoload_register(function ($class) {
$name = \str_replace('AlibabaCloud\\Client\\', '', $class);
$file = __DIR__ . \DIRECTORY_SEPARATOR . 'src' . \DIRECTORY_SEPARATOR . \str_replace('\\', \DIRECTORY_SEPARATOR, $name) . '.php';
if (\file_exists($file)) {
require_once $file;
return true;
}
return false;
});
{
"name": "alibabacloud/client",
"homepage": "https://www.alibabacloud.com/",
"description": "Alibaba Cloud Client for PHP - Use Alibaba Cloud in your PHP project",
"keywords": [
"sdk",
"tool",
"cloud",
"client",
"aliyun",
"library",
"alibaba",
"alibabacloud"
],
"type": "library",
"license": "Apache-2.0",
"support": {
"source": "https://github.com/aliyun/openapi-sdk-php-client",
"issues": "https://github.com/aliyun/openapi-sdk-php-client/issues"
},
"authors": [
{
"name": "Alibaba Cloud SDK",
"email": "sdk-team@alibabacloud.com",
"homepage": "http://www.alibabacloud.com"
}
],
"require": {
"php": ">=5.5",
"ext-curl": "*",
"ext-json": "*",
"ext-libxml": "*",
"ext-openssl": "*",
"ext-mbstring": "*",
"ext-simplexml": "*",
"ext-xmlwriter": "*",
"guzzlehttp/guzzle": "^6.3|^7.0",
"mtdowling/jmespath.php": "^2.5",
"adbario/php-dot-notation": "^2.4.1",
"clagiordano/weblibs-configmanager": "^1.0"
},
"require-dev": {
"ext-spl": "*",
"ext-dom": "*",
"ext-pcre": "*",
"psr/cache": "^1.0",
"ext-sockets": "*",
"drupal/coder": "^8.3",
"symfony/dotenv": "^3.4",
"league/climate": "^3.2.4",
"phpunit/phpunit": "^5.7|^6.6|^7.5|^8.5|^9.5",
"monolog/monolog": "^1.24",
"composer/composer": "^1.8",
"mikey179/vfsstream": "^1.6",
"symfony/var-dumper": "^3.4"
},
"suggest": {
"ext-sockets": "To use client-side monitoring"
},
"autoload": {
"psr-4": {
"AlibabaCloud\\Client\\": "src"
},
"files": [
"src/Functions.php"
]
},
"autoload-dev": {
"psr-4": {
"AlibabaCloud\\Client\\Tests\\": "tests/"
}
},
"config": {
"preferred-install": "dist",
"optimize-autoloader": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts-descriptions": {
"cs": "Tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard.",
"cbf": "Automatically correct coding standard violations.",
"fixer": "Fixes code to follow standards.",
"test": "Run all tests.",
"unit": "Run Unit tests.",
"feature": "Run Feature tests.",
"clearCache": "Clear cache like coverage.",
"coverage": "Show Coverage html.",
"endpoints": "Update endpoints from OSS."
},
"scripts": {
"cs": "phpcs --standard=PSR2 -n ./",
"cbf": "phpcbf --standard=PSR2 -n ./",
"fixer": "php-cs-fixer fix ./",
"test": [
"phpunit --colors=always"
],
"test4HighVersion": [
"@clearCache",
"phpunit --testsuite=Test4HighVersion --colors=always"
],
"test4LowVersion": [
"@clearCache",
"phpunit --testsuite=Test4LowVersion --colors=always"
],
"unit4HighVersion": [
"@clearCache",
"phpunit --testsuite=Unit4HighVersion --colors=always"
],
"unit4LowVersion": [
"@clearCache",
"phpunit --testsuite=Unit4LowVersion --colors=always"
],
"feature4HighVersion": [
"@clearCache",
"phpunit --testsuite=Feature4HighVersion --colors=always"
],
"feature4LowVersion": [
"@clearCache",
"phpunit --testsuite=Feature4LowVersion --colors=always"
],
"coverage": "open cache/coverage/index.html",
"clearCache": "rm -rf cache/*",
"endpoints": [
"AlibabaCloud\\Client\\Regions\\LocationService::updateEndpoints",
"@fixer"
],
"release": [
"AlibabaCloud\\Client\\Release::release"
]
}
}
<?php
namespace AlibabaCloud\Client;
/**
* Class Accept
*
* @package AlibabaCloud\Client
*/
class Accept
{
/**
* @var string
*/
private $format;
/**
* Accept constructor.
*
* @param string $format
*/
private function __construct($format)
{
$this->format = $format;
}
/**
* @param $format
*
* @return Accept
*/
public static function create($format)
{
return new static($format);
}
/**
* @return mixed|string
*/
public function toString()
{
$key = \strtoupper($this->format);
$list = [
'JSON' => 'application/json',
'XML' => 'application/xml',
'RAW' => 'application/octet-stream',
'FORM' => 'application/x-www-form-urlencoded'
];
return isset($list[$key]) ? $list[$key] : $list['RAW'];
}
}
<?php
namespace AlibabaCloud\Client;
use AlibabaCloud\Client\Traits\LogTrait;
use AlibabaCloud\Client\Traits\MockTrait;
use AlibabaCloud\Client\Traits\ClientTrait;
use AlibabaCloud\Client\Traits\HistoryTrait;
use AlibabaCloud\Client\Traits\RequestTrait;
use AlibabaCloud\Client\Traits\EndpointTrait;
use AlibabaCloud\Client\Traits\DefaultRegionTrait;
use AlibabaCloud\Client\Exception\ClientException;
/**
* Class AlibabaCloud
*
* @package AlibabaCloud\Client
* @mixin \AlibabaCloud\IdeHelper
*/
class AlibabaCloud
{
use ClientTrait;
use DefaultRegionTrait;
use EndpointTrait;
use RequestTrait;
use MockTrait;
use HistoryTrait;
use LogTrait;
/**
* Version of the Client
*/
const VERSION = '1.5.32';
/**
* This static method can directly call the specific service.
*
* @param string $product
* @param array $arguments
*
* @codeCoverageIgnore
* @return object
* @throws ClientException
*/
public static function __callStatic($product, $arguments)
{
$product = \ucfirst($product);
$product_class = 'AlibabaCloud' . '\\' . $product . '\\' . $product;
if (\class_exists($product_class)) {
return new $product_class;
}
throw new ClientException(
"May not yet support product $product quick access, "
. 'you can use [Alibaba Cloud Client for PHP] to send any custom '
. 'requests: https://github.com/aliyun/openapi-sdk-php-client/blob/master/docs/en-US/3-Request.md',
SDK::SERVICE_NOT_FOUND
);
}
}
<?php
namespace AlibabaCloud\Client\Clients;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Signature\ShaHmac1Signature;
use AlibabaCloud\Client\Credentials\AccessKeyCredential;
/**
* Use the AccessKey to complete the authentication.
*
* @package AlibabaCloud\Client\Clients
*/
class AccessKeyClient extends Client
{
/**
* @param string $accessKeyId
* @param string $accessKeySecret
*
* @throws ClientException
*/
public function __construct($accessKeyId, $accessKeySecret)
{
parent::__construct(
new AccessKeyCredential($accessKeyId, $accessKeySecret),
new ShaHmac1Signature()
);
}
}
<?php
namespace AlibabaCloud\Client\Clients;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Signature\BearerTokenSignature;
use AlibabaCloud\Client\Credentials\BearerTokenCredential;
/**
* Use the Bearer Token to complete the authentication.
*
* @package AlibabaCloud\Client\Clients
*/
class BearerTokenClient extends Client
{
/**
* @param string $bearerToken
*
* @throws ClientException
*/
public function __construct($bearerToken)
{
parent::__construct(
new BearerTokenCredential($bearerToken),
new BearerTokenSignature()
);
}
}
<?php
namespace AlibabaCloud\Client\Clients;
use AlibabaCloud\Client\Request\Request;
use AlibabaCloud\Client\Traits\HttpTrait;
use AlibabaCloud\Client\Traits\RegionTrait;
use AlibabaCloud\Client\Credentials\StsCredential;
use AlibabaCloud\Client\Signature\ShaHmac1Signature;
use AlibabaCloud\Client\Signature\SignatureInterface;
use AlibabaCloud\Client\Signature\ShaHmac256Signature;
use AlibabaCloud\Client\Signature\BearerTokenSignature;
use AlibabaCloud\Client\Credentials\AccessKeyCredential;
use AlibabaCloud\Client\Credentials\CredentialsInterface;
use AlibabaCloud\Client\Credentials\EcsRamRoleCredential;
use AlibabaCloud\Client\Credentials\RamRoleArnCredential;
use AlibabaCloud\Client\Credentials\RsaKeyPairCredential;
use AlibabaCloud\Client\Credentials\BearerTokenCredential;
use AlibabaCloud\Client\Signature\ShaHmac256WithRsaSignature;
/**
* Custom Client.
*
* @package AlibabaCloud\Client\Clients
*/
class Client
{
use HttpTrait;
use RegionTrait;
use ManageTrait;
/**
* @var CredentialsInterface|AccessKeyCredential|BearerTokenCredential|StsCredential|EcsRamRoleCredential|RamRoleArnCredential|RsaKeyPairCredential
*/
private $credential;
/**
* @var SignatureInterface
*/
private $signature;
/**
* Self constructor.
*
* @param CredentialsInterface $credential
* @param SignatureInterface $signature
*/
public function __construct(CredentialsInterface $credential, SignatureInterface $signature)
{
$this->credential = $credential;
$this->signature = $signature;
$this->options['connect_timeout'] = Request::CONNECT_TIMEOUT;
$this->options['timeout'] = Request::TIMEOUT;
$this->options['verify'] = false;
}
/**
* @return AccessKeyCredential|BearerTokenCredential|CredentialsInterface|EcsRamRoleCredential|RamRoleArnCredential|RsaKeyPairCredential|StsCredential
*/
public function getCredential()
{
return $this->credential;
}
/**
* @return SignatureInterface|BearerTokenSignature|ShaHmac1Signature|ShaHmac256Signature|ShaHmac256WithRsaSignature
*/
public function getSignature()
{
return $this->signature;
}
}
<?php
namespace AlibabaCloud\Client\Clients;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Signature\ShaHmac1Signature;
use AlibabaCloud\Client\Credentials\EcsRamRoleCredential;
/**
* Use the RAM role of an ECS instance to complete the authentication.
*/
class EcsRamRoleClient extends Client
{
/**
* @param string $roleName
*
* @throws ClientException
*/
public function __construct($roleName)
{
parent::__construct(
new EcsRamRoleCredential($roleName),
new ShaHmac1Signature()
);
}
}
<?php
namespace AlibabaCloud\Client\Clients;
use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Filter\Filter;
use AlibabaCloud\Client\Request\Request;
use AlibabaCloud\Client\Credentials\StsCredential;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;
use AlibabaCloud\Client\Credentials\CredentialsInterface;
use AlibabaCloud\Client\Credentials\EcsRamRoleCredential;
use AlibabaCloud\Client\Credentials\RamRoleArnCredential;
use AlibabaCloud\Client\Credentials\RsaKeyPairCredential;
use AlibabaCloud\Client\Credentials\Providers\EcsRamRoleProvider;
use AlibabaCloud\Client\Credentials\Providers\RamRoleArnProvider;
use AlibabaCloud\Client\Credentials\Providers\RsaKeyPairProvider;
use AlibabaCloud\Client\Credentials\Providers\CredentialsProvider;
/**
* Trait ManageTrait.
*
* @mixin Client
*/
trait ManageTrait
{
/**
* @param int $timeout
* @param int $connectTimeout
*
* @return CredentialsInterface|StsCredential
*
* @throws ClientException
* @throws ServerException
*/
public function getSessionCredential($timeout = Request::TIMEOUT, $connectTimeout = Request::CONNECT_TIMEOUT)
{
switch (\get_class($this->credential)) {
case EcsRamRoleCredential::class:
return (new EcsRamRoleProvider($this))->get();
case RamRoleArnCredential::class:
return (new RamRoleArnProvider($this))->get($timeout, $connectTimeout);
case RsaKeyPairCredential::class:
return (new RsaKeyPairProvider($this))->get($timeout, $connectTimeout);
default:
return $this->credential;
}
}
/**
* @return static
* @throws ClientException
* @deprecated
* @codeCoverageIgnore
*/
public function asGlobalClient()
{
return $this->asDefaultClient();
}
/**
* Set the current client as the default client.
*
* @return static
* @throws ClientException
*/
public function asDefaultClient()
{
return $this->name(CredentialsProvider::getDefaultName());
}
/**
* Naming clients.
*
* @param string $name
*
* @return static
* @throws ClientException
*/
public function name($name)
{
Filter::name($name);
return AlibabaCloud::set($name, $this);
}
/**
* @return bool
*/
public function isDebug()
{
if (isset($this->options['debug'])) {
return $this->options['debug'] === true && PHP_SAPI === 'cli';
}
return false;
}
}
<?php
namespace AlibabaCloud\Client\Clients;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Signature\ShaHmac1Signature;
use AlibabaCloud\Client\Credentials\RamRoleArnCredential;
/**
* Use the AssumeRole of the RAM account to complete the authentication.
*
* @package AlibabaCloud\Client\Clients
*/
class RamRoleArnClient extends Client
{
/**
* @param string $accessKeyId
* @param string $accessKeySecret
* @param string $roleArn
* @param string $roleSessionName
* @param string|array $policy
*
* @throws ClientException
*/
public function __construct($accessKeyId, $accessKeySecret, $roleArn, $roleSessionName, $policy = '')
{
parent::__construct(
new RamRoleArnCredential($accessKeyId, $accessKeySecret, $roleArn, $roleSessionName, $policy),
new ShaHmac1Signature()
);
}
}
<?php
namespace AlibabaCloud\Client\Clients;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Signature\ShaHmac1Signature;
use AlibabaCloud\Client\Credentials\RsaKeyPairCredential;
/**
* Use the RSA key pair to complete the authentication (supported only on Japanese site)
*
* @package AlibabaCloud\Client\Clients
*/
class RsaKeyPairClient extends Client
{
/**
* @param string $publicKeyId
* @param string $privateKeyFile
*
* @throws ClientException
*/
public function __construct($publicKeyId, $privateKeyFile)
{
parent::__construct(
new RsaKeyPairCredential($publicKeyId, $privateKeyFile),
new ShaHmac1Signature()
);
}
}
<?php
namespace AlibabaCloud\Client\Clients;
use AlibabaCloud\Client\Credentials\StsCredential;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Signature\ShaHmac1Signature;
/**
* Use the STS Token to complete the authentication.
*/
class StsClient extends Client
{
/**
* @param string $accessKeyId Access key ID
* @param string $accessKeySecret Access Key Secret
* @param string $securityToken Security Token
*
* @throws ClientException
*/
public function __construct($accessKeyId, $accessKeySecret, $securityToken = '')
{
parent::__construct(
new StsCredential($accessKeyId, $accessKeySecret, $securityToken),
new ShaHmac1Signature()
);
}
}
<?php
namespace AlibabaCloud\Client\Config;
use Exception;
use clagiordano\weblibs\configmanager\ConfigManager;
/**
* Class Config
*
* @package AlibabaCloud\Client\Config
*/
class Config
{
/**
* @var ConfigManager|null
*/
private static $configManager;
/**
* @param string $configPath
*
* @param string|null $defaultValue
*
* @return mixed
*/
public static function get($configPath, $defaultValue = null)
{
return self::getConfigManager()
->getValue(
\strtolower($configPath),
$defaultValue
);
}
/**
* @return ConfigManager
*/
private static function getConfigManager()
{
if (!self::$configManager instanceof ConfigManager) {
self::$configManager = new ConfigManager(__DIR__ . DIRECTORY_SEPARATOR . 'Data.php');
}
return self::$configManager;
}
/**
* @param string $configPath
* @param mixed $newValue
*
* @return ConfigManager
* @throws Exception
*/
public static function set($configPath, $newValue)
{
self::getConfigManager()->setValue(\strtolower($configPath), $newValue);
return self::getConfigManager()->saveConfigFile();
}
}
This diff is collapsed.
<?php
namespace AlibabaCloud\Client\Credentials;
use AlibabaCloud\Client\Filter\CredentialFilter;
use AlibabaCloud\Client\Exception\ClientException;
/**
* Use the AccessKey to complete the authentication.
*
* @package AlibabaCloud\Client\Credentials
*/
class AccessKeyCredential implements CredentialsInterface
{
/**
* @var string
*/
private $accessKeyId;
/**
* @var string
*/
private $accessKeySecret;
/**
* AccessKeyCredential constructor.
*
* @param string $accessKeyId Access key ID
* @param string $accessKeySecret Access Key Secret
*
* @throws ClientException
*/
public function __construct($accessKeyId, $accessKeySecret)
{
CredentialFilter::AccessKey($accessKeyId, $accessKeySecret);
$this->accessKeyId = $accessKeyId;
$this->accessKeySecret = $accessKeySecret;
}
/**
* @return string
*/
public function getAccessKeyId()
{
return $this->accessKeyId;
}
/**
* @return string
*/
public function getAccessKeySecret()
{
return $this->accessKeySecret;
}
/**
* @return string
*/
public function __toString()
{
return "$this->accessKeyId#$this->accessKeySecret";
}
}
<?php
namespace AlibabaCloud\Client\Credentials;
use AlibabaCloud\Client\Filter\CredentialFilter;
use AlibabaCloud\Client\Exception\ClientException;
/**
* Class BearerTokenCredential
*
* @package AlibabaCloud\Client\Credentials
*/
class BearerTokenCredential implements CredentialsInterface
{
/**
* @var string
*/
private $bearerToken;
/**
* Class constructor.
*
* @param string $bearerToken
*
* @throws ClientException
*/
public function __construct($bearerToken)
{
CredentialFilter::bearerToken($bearerToken);
$this->bearerToken = $bearerToken;
}
/**
* @return string
*/
public function getBearerToken()
{
return $this->bearerToken;
}
/**
* @return string
*/
public function getAccessKeyId()
{
return '';
}
/**
* @return string
*/
public function getAccessKeySecret()
{
return '';
}
/**
* @return string
*/
public function __toString()
{
return "bearerToken#$this->bearerToken";
}
}
<?php
namespace AlibabaCloud\Client\Credentials;
/**
* interface CredentialsInterface
*
* @package AlibabaCloud\Client\Credentials
*
* @codeCoverageIgnore
*/
interface CredentialsInterface
{
/**
* @return string
*/
public function __toString();
}
<?php
namespace AlibabaCloud\Client\Credentials;
use AlibabaCloud\Client\Filter\CredentialFilter;
use AlibabaCloud\Client\Exception\ClientException;
/**
* Use the RAM role of an ECS instance to complete the authentication.
*
* @package AlibabaCloud\Client\Credentials
*/
class EcsRamRoleCredential implements CredentialsInterface
{
/**
* @var string
*/
private $roleName;
/**
* Class constructor.
*
* @param string $roleName
*
* @throws ClientException
*/
public function __construct($roleName)
{
CredentialFilter::roleName($roleName);
$this->roleName = $roleName;
}
/**
* @return string
*/
public function getRoleName()
{
return $this->roleName;
}
/**
* @return string
*/
public function __toString()
{
return "roleName#$this->roleName";
}
}
<?php
namespace AlibabaCloud\Client\Credentials\Ini;
use AlibabaCloud\Client\SDK;
use AlibabaCloud\Client\Clients\Client;
use AlibabaCloud\Client\Clients\AccessKeyClient;
use AlibabaCloud\Client\Clients\RamRoleArnClient;
use AlibabaCloud\Client\Clients\RsaKeyPairClient;
use AlibabaCloud\Client\Clients\EcsRamRoleClient;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Clients\BearerTokenClient;
/**
* Trait CreateTrait
*
* @package AlibabaCloud\Client\Credentials\Ini
*
* @mixin IniCredential
*/
trait CreateTrait
{
/**
* @param string $clientName
* @param array $credential
*
* @return Client|bool
* @throws ClientException
*/
protected function createClient($clientName, array $credential)
{
if (!isset($credential['enable']) || !$credential['enable']) {
return false;
}
if (!isset($credential['type'])) {
$this->missingRequired('type', $clientName);
}
return $this->createClientByType($clientName, $credential)->name($clientName);
}
/**
* @param string $clientName
* @param array $credential
*
* @return AccessKeyClient|BearerTokenClient|EcsRamRoleClient|RamRoleArnClient|RsaKeyPairClient
* @throws ClientException
*/
private function createClientByType($clientName, array $credential)
{
switch (\strtolower($credential['type'])) {
case 'access_key':
return $this->accessKeyClient($clientName, $credential);
case 'ecs_ram_role':
return $this->ecsRamRoleClient($clientName, $credential);
case 'ram_role_arn':
return $this->ramRoleArnClient($clientName, $credential);
case 'bearer_token':
return $this->bearerTokenClient($clientName, $credential);
case 'rsa_key_pair':
return $this->rsaKeyPairClient($clientName, $credential);
default:
throw new ClientException(
"Invalid type '{$credential['type']}' for '$clientName' in {$this->filename}",
SDK::INVALID_CREDENTIAL
);
}
}
/**
* @param array $credential
* @param string $clientName
*
* @return AccessKeyClient
* @throws ClientException
*/
private function accessKeyClient($clientName, array $credential)
{
if (!isset($credential['access_key_id'])) {
$this->missingRequired('access_key_id', $clientName);
}
if (!isset($credential['access_key_secret'])) {
$this->missingRequired('access_key_secret', $clientName);
}
return new AccessKeyClient(
$credential['access_key_id'],
$credential['access_key_secret']
);
}
/**
* @param string $clientName
* @param array $credential
*
* @return EcsRamRoleClient
* @throws ClientException
*/
private function ecsRamRoleClient($clientName, array $credential)
{
if (!isset($credential['role_name'])) {
$this->missingRequired('role_name', $clientName);
}
return new EcsRamRoleClient($credential['role_name']);
}
/**
* @param string $clientName
* @param array $credential
*
* @return RamRoleArnClient
* @throws ClientException
*/
private function ramRoleArnClient($clientName, array $credential)
{
if (!isset($credential['access_key_id'])) {
$this->missingRequired('access_key_id', $clientName);
}
if (!isset($credential['access_key_secret'])) {
$this->missingRequired('access_key_secret', $clientName);
}
if (!isset($credential['role_arn'])) {
$this->missingRequired('role_arn', $clientName);
}
if (!isset($credential['role_session_name'])) {
$this->missingRequired('role_session_name', $clientName);
}
return new RamRoleArnClient(
$credential['access_key_id'],
$credential['access_key_secret'],
$credential['role_arn'],
$credential['role_session_name']
);
}
/**
* @param string $clientName
* @param array $credential
*
* @return BearerTokenClient
* @throws ClientException
*/
private function bearerTokenClient($clientName, array $credential)
{
if (!isset($credential['bearer_token'])) {
$this->missingRequired('bearer_token', $clientName);
}
return new BearerTokenClient($credential['bearer_token']);
}
/**
* @param array $credential
* @param string $clientName
*
* @return RsaKeyPairClient
* @throws ClientException
*/
private function rsaKeyPairClient($clientName, array $credential)
{
if (!isset($credential['public_key_id'])) {
$this->missingRequired('public_key_id', $clientName);
}
if (!isset($credential['private_key_file'])) {
$this->missingRequired('private_key_file', $clientName);
}
return new RsaKeyPairClient(
$credential['public_key_id'],
$credential['private_key_file']
);
}
}
<?php
namespace AlibabaCloud\Client\Credentials\Ini;
use AlibabaCloud\Client\SDK;
use AlibabaCloud\Client\Clients\Client;
use AlibabaCloud\Client\Exception\ClientException;
/**
* Class IniCredential
*
* @package AlibabaCloud\Client\Credentials\Ini
*/
class IniCredential
{
use CreateTrait;
use OptionsTrait;
/**
* @var array
*/
private static $hasLoaded;
/**
* @var string
*/
protected $filename;
/**
* IniCredential constructor.
*
* @param string $filename
*/
public function __construct($filename = '')
{
$this->filename = $filename ?: $this->getDefaultFile();
}
/**
* Get the default credential file.
*
* @return string
*/
public function getDefaultFile()
{
return self::getHomeDirectory() . DIRECTORY_SEPARATOR . '.alibabacloud' . DIRECTORY_SEPARATOR . 'credentials';
}
/**
* Gets the environment's HOME directory.
*
* @return null|string
*/
private static function getHomeDirectory()
{
if (getenv('HOME')) {
return getenv('HOME');
}
return (getenv('HOMEDRIVE') && getenv('HOMEPATH'))
? getenv('HOMEDRIVE') . getenv('HOMEPATH')
: null;
}
/**
* Clear credential cache.
*
* @return void
*/
public static function forgetLoadedCredentialsFile()
{
self::$hasLoaded = [];
}
/**
* Get the credential file.
*
* @return string
*/
public function getFilename()
{
return $this->filename;
}
/**
* @param array $array
* @param string $key
*
* @return bool
*/
protected static function isNotEmpty(array $array, $key)
{
return isset($array[$key]) && !empty($array[$key]);
}
/**
* @param string $key
* @param string $clientName
*
* @throws ClientException
*/
public function missingRequired($key, $clientName)
{
throw new ClientException(
"Missing required '$key' option for '$clientName' in " . $this->getFilename(),
SDK::INVALID_CREDENTIAL
);
}
/**
* @return array|mixed
* @throws ClientException
*/
public function load()
{
// If it has been loaded, assign the client directly.
if (isset(self::$hasLoaded[$this->filename])) {
/**
* @var $client Client
*/
foreach (self::$hasLoaded[$this->filename] as $projectName => $client) {
$client->name($projectName);
}
return self::$hasLoaded[$this->filename];
}
return $this->loadFile();
}
/**
* Exceptions will be thrown if the file is unreadable and not the default file.
*
* @return array|mixed
* @throws ClientException
*/
private function loadFile()
{
if (!\AlibabaCloud\Client\inOpenBasedir($this->filename)) {
return [];
}
if (!\is_readable($this->filename) || !\is_file($this->filename)) {
if ($this->filename === $this->getDefaultFile()) {
// @codeCoverageIgnoreStart
return [];
// @codeCoverageIgnoreEnd
}
throw new ClientException(
'Credential file is not readable: ' . $this->getFilename(),
SDK::INVALID_CREDENTIAL
);
}
return $this->parseFile();
}
/**
* Decode the ini file into an array.
*
* @return array|mixed
* @throws ClientException
*/
private function parseFile()
{
try {
$file = \parse_ini_file($this->filename, true);
if (\is_array($file) && $file !== []) {
return $this->initClients($file);
}
throw new ClientException(
'Format error: ' . $this->getFilename(),
SDK::INVALID_CREDENTIAL
);
} catch (\Exception $e) {
throw new ClientException(
$e->getMessage(),
SDK::INVALID_CREDENTIAL,
$e
);
}
}
/**
* Initialize clients.
*
* @param array $array
*
* @return array|mixed
* @throws ClientException
*/
private function initClients($array)
{
foreach (\array_change_key_case($array) as $clientName => $configures) {
$configures = \array_change_key_case($configures);
$clientInstance = $this->createClient($clientName, $configures);
if ($clientInstance instanceof Client) {
self::$hasLoaded[$this->filename][$clientName] = $clientInstance;
self::setClientAttributes($configures, $clientInstance);
self::setCert($configures, $clientInstance);
self::setProxy($configures, $clientInstance);
}
}
return isset(self::$hasLoaded[$this->filename])
? self::$hasLoaded[$this->filename]
: [];
}
}
<?php
namespace AlibabaCloud\Client\Credentials\Ini;
use AlibabaCloud\Client\Clients\Client;
use AlibabaCloud\Client\Exception\ClientException;
/**
* Trait OptionsTrait
*
* @package AlibabaCloud\Client\Credentials\Ini
*
* @mixin IniCredential
*/
trait OptionsTrait
{
/**
* @param array $configures
* @param Client $client
*
* @throws ClientException
*/
private static function setClientAttributes($configures, Client $client)
{
if (self::isNotEmpty($configures, 'region_id')) {
$client->regionId($configures['region_id']);
}
if (isset($configures['debug'])) {
$client->options(
[
'debug' => (bool)$configures['debug'],
]
);
}
if (self::isNotEmpty($configures, 'timeout')) {
$client->options(
[
'timeout' => $configures['timeout'],
]
);
}
if (self::isNotEmpty($configures, 'connect_timeout')) {
$client->options(
[
'connect_timeout' => $configures['connect_timeout'],
]
);
}
}
/**
* @param array $configures
* @param Client $client
*/
private static function setProxy($configures, Client $client)
{
if (self::isNotEmpty($configures, 'proxy')) {
$client->options(
[
'proxy' => $configures['proxy'],
]
);
}
$proxy = [];
if (self::isNotEmpty($configures, 'proxy_http')) {
$proxy['http'] = $configures['proxy_http'];
}
if (self::isNotEmpty($configures, 'proxy_https')) {
$proxy['https'] = $configures['proxy_https'];
}
if (self::isNotEmpty($configures, 'proxy_no')) {
$proxy['no'] = \explode(',', $configures['proxy_no']);
}
if ($proxy !== []) {
$client->options(
[
'proxy' => $proxy,
]
);
}
}
/**
* @param array $configures
* @param Client $client
*/
private static function setCert($configures, Client $client)
{
if (self::isNotEmpty($configures, 'cert_file') && !self::isNotEmpty($configures, 'cert_password')) {
$client->options(
[
'cert' => $configures['cert_file'],
]
);
}
if (self::isNotEmpty($configures, 'cert_file') && self::isNotEmpty($configures, 'cert_password')) {
$client->options(
[
'cert' => [
$configures['cert_file'],
$configures['cert_password'],
],
]
);
}
}
}
<?php
namespace AlibabaCloud\Client\Credentials\Providers;
use Closure;
use AlibabaCloud\Client\SDK;
use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Exception\ClientException;
/**
* Class CredentialsProvider
*
* @package AlibabaCloud\Client\Credentials\Providers
*/
class CredentialsProvider
{
/**
* @var array
*/
private static $customChains;
/**
* @throws ClientException
*/
public static function chain()
{
$providers = func_get_args();
if (empty($providers)) {
throw new ClientException('No providers in chain', SDK::INVALID_ARGUMENT);
}
foreach ($providers as $provider) {
if (!$provider instanceof Closure) {
throw new ClientException('Providers must all be Closures', SDK::INVALID_ARGUMENT);
}
}
self::$customChains = $providers;
}
/**
* Forget the custom providers chain.
*/
public static function flush()
{
self::$customChains = [];
}
/**
* @return bool
*/
public static function hasCustomChain()
{
return (bool)self::$customChains;
}
/**
* @param string $clientName
*
* @throws ClientException
*/
public static function customProvider($clientName)
{
foreach (self::$customChains as $provider) {
$provider();
if (AlibabaCloud::has($clientName)) {
break;
}
}
}
/**
* @param string $clientName
*
* @throws ClientException
*/
public static function defaultProvider($clientName)
{
$providers = [
self::env(),
self::ini(),
self::instance(),
];
foreach ($providers as $provider) {
$provider();
if (AlibabaCloud::has($clientName)) {
break;
}
}
}
/**
* @return Closure
*/
public static function env()
{
return static function () {
$accessKeyId = \AlibabaCloud\Client\envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_ID');
$accessKeySecret = \AlibabaCloud\Client\envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_SECRET');
if ($accessKeyId && $accessKeySecret) {
AlibabaCloud::accessKeyClient($accessKeyId, $accessKeySecret)->asDefaultClient();
}
};
}
/**
* @return Closure
*/
public static function ini()
{
return static function () {
$ini = \AlibabaCloud\Client\envNotEmpty('ALIBABA_CLOUD_CREDENTIALS_FILE');
if ($ini) {
AlibabaCloud::load($ini);
} else {
// @codeCoverageIgnoreStart
AlibabaCloud::load();
// @codeCoverageIgnoreEnd
}
self::compatibleWithGlobal();
};
}
/**
* @codeCoverageIgnore
*
* Compatible with global
*
* @throws ClientException
*/
private static function compatibleWithGlobal()
{
if (AlibabaCloud::has('global') && !AlibabaCloud::has(self::getDefaultName())) {
AlibabaCloud::get('global')->name(self::getDefaultName());
}
}
/**
* @return array|false|string
* @throws ClientException
*/
public static function getDefaultName()
{
$name = \AlibabaCloud\Client\envNotEmpty('ALIBABA_CLOUD_PROFILE');
if ($name) {
return $name;
}
return 'default';
}
/**
* @return Closure
*/
public static function instance()
{
return static function () {
$instance = \AlibabaCloud\Client\envNotEmpty('ALIBABA_CLOUD_ECS_METADATA');
if ($instance) {
AlibabaCloud::ecsRamRoleClient($instance)->asDefaultClient();
}
};
}
}
<?php
namespace AlibabaCloud\Client\Credentials\Providers;
use Exception;
use AlibabaCloud\Client\Support\Stringy;
use AlibabaCloud\Client\SDK;
use AlibabaCloud\Client\Result\Result;
use Psr\Http\Message\ResponseInterface;
use GuzzleHttp\Exception\GuzzleException;
use AlibabaCloud\Client\Request\RpcRequest;
use AlibabaCloud\Client\Credentials\StsCredential;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;
use AlibabaCloud\Client\Credentials\EcsRamRoleCredential;
/**
* Class EcsRamRoleProvider
*
* @package AlibabaCloud\Client\Credentials\Providers
*/
class EcsRamRoleProvider extends Provider
{
/**
* Expiration time slot for temporary security credentials.
*
* @var int
*/
protected $expirationSlot = 10;
/**
* @var string
*/
private $uri = 'http://100.100.100.200/latest/meta-data/ram/security-credentials/';
/**
* Get credential.
*
* @return StsCredential
* @throws ClientException
* @throws ServerException
*/
public function get()
{
$result = $this->getCredentialsInCache();
if ($result === null) {
$result = $this->request();
if (!isset($result['AccessKeyId'], $result['AccessKeySecret'], $result['SecurityToken'])) {
throw new ServerException($result, $this->error, SDK::INVALID_CREDENTIAL);
}
$this->cache($result->toArray());
}
return new StsCredential(
$result['AccessKeyId'],
$result['AccessKeySecret'],
$result['SecurityToken']
);
}
/**
* Get credentials by request.
*
* @return Result
* @throws ClientException
* @throws ServerException
*/
public function request()
{
$result = $this->getResponse();
if ($result->getStatusCode() === 404) {
$message = 'The role was not found in the instance';
throw new ClientException($message, SDK::INVALID_CREDENTIAL);
}
if (!$result->isSuccess()) {
$message = 'Error retrieving credentials from result';
throw new ServerException($result, $message, SDK::INVALID_CREDENTIAL);
}
return $result;
}
/**
* Get data from meta.
*
* @return mixed|ResponseInterface
* @throws ClientException
* @throws Exception
*/
public function getResponse()
{
/**
* @var EcsRamRoleCredential $credential
*/
$credential = $this->client->getCredential();
$url = $this->uri . $credential->getRoleName();
$options = [
'http_errors' => false,
'timeout' => 1,
'connect_timeout' => 1,
'debug' => $this->client->isDebug(),
];
try {
return RpcRequest::createClient()->request('GET', $url, $options);
} catch (GuzzleException $exception) {
if (Stringy::contains($exception->getMessage(), 'timed')) {
$message = 'Timeout or instance does not belong to Alibaba Cloud';
} else {
$message = $exception->getMessage();
}
throw new ClientException(
$message,
SDK::SERVER_UNREACHABLE,
$exception
);
}
}
}
<?php
namespace AlibabaCloud\Client\Credentials\Providers;
use AlibabaCloud\Client\Clients\Client;
/**
* Class Provider
*
* @package AlibabaCloud\Client\Credentials\Providers
*/
class Provider
{
/**
* For TSC Duration Seconds
*/
const DURATION_SECONDS = 3600;
/**
* @var array
*/
protected static $credentialsCache = [];
/**
* Expiration time slot for temporary security credentials.
*
* @var int
*/
protected $expirationSlot = 180;
/**
* @var Client
*/
protected $client;
/**
* @var string
*/
protected $error = 'Result contains no credentials';
/**
* CredentialTrait constructor.
*
* @param Client $client
*/
public function __construct(Client $client)
{
$this->client = $client;
}
/**
* Get the credentials from the cache in the validity period.
*
* @return array|null
*/
public function getCredentialsInCache()
{
if (isset(self::$credentialsCache[$this->key()])) {
$result = self::$credentialsCache[$this->key()];
if (\strtotime($result['Expiration']) - \time() >= $this->expirationSlot) {
return $result;
}
unset(self::$credentialsCache[$this->key()]);
}
return null;
}
/**
* Get the toString of the credentials as the key.
*
* @return string
*/
protected function key()
{
return (string)$this->client->getCredential();
}
/**
* Cache credentials.
*
* @param array $credential
*/
protected function cache(array $credential)
{
self::$credentialsCache[$this->key()] = $credential;
}
}
<?php
namespace AlibabaCloud\Client\Credentials\Providers;
use AlibabaCloud\Client\SDK;
use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Result\Result;
use AlibabaCloud\Client\Request\Request;
use AlibabaCloud\Client\Credentials\StsCredential;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;
use AlibabaCloud\Client\Credentials\Requests\AssumeRole;
/**
* Class RamRoleArnProvider
*
* @package AlibabaCloud\Client\Credentials\Providers
*/
class RamRoleArnProvider extends Provider
{
/**
* Get credential.
*
*
* @param int $timeout
* @param int $connectTimeout
*
* @return StsCredential
* @throws ClientException
* @throws ServerException
*/
public function get($timeout = Request::TIMEOUT, $connectTimeout = Request::CONNECT_TIMEOUT)
{
$credential = $this->getCredentialsInCache();
if (null === $credential) {
$result = $this->request($timeout, $connectTimeout);
if (!isset($result['Credentials']['AccessKeyId'],
$result['Credentials']['AccessKeySecret'],
$result['Credentials']['SecurityToken'])) {
throw new ServerException($result, $this->error, SDK::INVALID_CREDENTIAL);
}
$credential = $result['Credentials'];
$this->cache($credential);
}
return new StsCredential(
$credential['AccessKeyId'],
$credential['AccessKeySecret'],
$credential['SecurityToken']
);
}
/**
* Get credentials by request.
*
* @param $timeout
* @param $connectTimeout
*
* @return Result
* @throws ClientException
* @throws ServerException
*/
private function request($timeout, $connectTimeout)
{
$clientName = __CLASS__ . \uniqid('ak', true);
$credential = $this->client->getCredential();
AlibabaCloud::accessKeyClient(
$credential->getAccessKeyId(),
$credential->getAccessKeySecret()
)->name($clientName);
return (new AssumeRole($credential))
->client($clientName)
->timeout($timeout)
->connectTimeout($connectTimeout)
->debug($this->client->isDebug())
->request();
}
}
<?php
namespace AlibabaCloud\Client\Credentials\Providers;
use AlibabaCloud\Client\SDK;
use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Result\Result;
use AlibabaCloud\Client\Request\Request;
use AlibabaCloud\Client\Credentials\StsCredential;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;
use AlibabaCloud\Client\Credentials\AccessKeyCredential;
use AlibabaCloud\Client\Signature\ShaHmac256WithRsaSignature;
use AlibabaCloud\Client\Credentials\Requests\GenerateSessionAccessKey;
/**
* Class RsaKeyPairProvider
*
* @package AlibabaCloud\Client\Credentials\Providers
*/
class RsaKeyPairProvider extends Provider
{
/**
* Get credential.
*
* @param int $timeout
* @param int $connectTimeout
*
* @return StsCredential
* @throws ClientException
* @throws ServerException
*/
public function get($timeout = Request::TIMEOUT, $connectTimeout = Request::CONNECT_TIMEOUT)
{
$credential = $this->getCredentialsInCache();
if ($credential === null) {
$result = $this->request($timeout, $connectTimeout);
if (!isset($result['SessionAccessKey']['SessionAccessKeyId'],
$result['SessionAccessKey']['SessionAccessKeySecret'])) {
throw new ServerException($result, $this->error, SDK::INVALID_CREDENTIAL);
}
$credential = $result['SessionAccessKey'];
$this->cache($credential);
}
return new StsCredential(
$credential['SessionAccessKeyId'],
$credential['SessionAccessKeySecret']
);
}
/**
* Get credentials by request.
*
* @param $timeout
* @param $connectTimeout
*
* @return Result
* @throws ClientException
* @throws ServerException
*/
private function request($timeout, $connectTimeout)
{
$clientName = __CLASS__ . \uniqid('rsa', true);
$credential = $this->client->getCredential();
AlibabaCloud::client(
new AccessKeyCredential(
$credential->getPublicKeyId(),
$credential->getPrivateKey()
),
new ShaHmac256WithRsaSignature()
)->name($clientName);
return (new GenerateSessionAccessKey($credential->getPublicKeyId()))
->client($clientName)
->timeout($timeout)
->connectTimeout($connectTimeout)
->debug($this->client->isDebug())
->request();
}
}
<?php
namespace AlibabaCloud\Client\Credentials;
use AlibabaCloud\Client\Filter\CredentialFilter;
use AlibabaCloud\Client\Exception\ClientException;
/**
* Use the AssumeRole of the RAM account to complete the authentication.
*
* @package AlibabaCloud\Client\Credentials
*/
class RamRoleArnCredential implements CredentialsInterface
{
/**
* @var string
*/
private $accessKeyId;
/**
* @var string
*/
private $accessKeySecret;
/**
* @var string
*/
private $roleArn;
/**
* @var string
*/
private $roleSessionName;
/**
* @var string
*/
private $policy;
/**
* Class constructor.
*
* @param string $accessKeyId
* @param string $accessKeySecret
* @param string $roleArn
* @param string $roleSessionName
* @param string|array $policy
*
* @throws ClientException
*/
public function __construct($accessKeyId, $accessKeySecret, $roleArn, $roleSessionName, $policy = '')
{
CredentialFilter::AccessKey($accessKeyId, $accessKeySecret);
$this->accessKeyId = $accessKeyId;
$this->accessKeySecret = $accessKeySecret;
$this->roleArn = $roleArn;
$this->roleSessionName = $roleSessionName;
$this->policy = $policy;
}
/**
* @return string
*/
public function getAccessKeyId()
{
return $this->accessKeyId;
}
/**
* @return string
*/
public function getAccessKeySecret()
{
return $this->accessKeySecret;
}
/**
* @return string
*/
public function getRoleArn()
{
return $this->roleArn;
}
/**
* @return string
*/
public function getRoleSessionName()
{
return $this->roleSessionName;
}
/**
* @return string
*/
public function getPolicy()
{
return $this->policy;
}
/**
* @return string
*/
public function __toString()
{
return "$this->accessKeyId#$this->accessKeySecret#$this->roleArn#$this->roleSessionName";
}
}
<?php
namespace AlibabaCloud\Client\Credentials\Requests;
use AlibabaCloud\Client\Request\RpcRequest;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Credentials\Providers\Provider;
use AlibabaCloud\Client\Credentials\RamRoleArnCredential;
/**
* Retrieving assume role credentials.
*
* @package AlibabaCloud\Client\Credentials\Requests
*/
class AssumeRole extends RpcRequest
{
/**
* AssumeRole constructor.
*
* @param RamRoleArnCredential $arnCredential
*
* @throws ClientException
*/
public function __construct(RamRoleArnCredential $arnCredential)
{
parent::__construct();
$this->product('Sts');
$this->version('2015-04-01');
$this->action('AssumeRole');
$this->host('sts.aliyuncs.com');
$this->scheme('https');
$this->regionId('cn-hangzhou');
$this->options['verify'] = false;
$this->options['query']['RoleArn'] = $arnCredential->getRoleArn();
$this->options['query']['RoleSessionName'] = $arnCredential->getRoleSessionName();
$this->options['query']['DurationSeconds'] = Provider::DURATION_SECONDS;
if ($arnCredential->getPolicy()) {
if (is_array($arnCredential->getPolicy())) {
$this->options['query']['Policy'] = json_encode($arnCredential->getPolicy());
}
if (is_string($arnCredential->getPolicy())) {
$this->options['query']['Policy'] = $arnCredential->getPolicy();
}
}
}
}
<?php
namespace AlibabaCloud\Client\Credentials\Requests;
use AlibabaCloud\Client\Request\RpcRequest;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Credentials\Providers\Provider;
/**
* Use the RSA key pair to complete the authentication (supported only on Japanese site)
*
* @package AlibabaCloud\Client\Credentials\Requests
*/
class GenerateSessionAccessKey extends RpcRequest
{
/**
* GenerateSessionAccessKey constructor.
*
* @param string $publicKeyId
*
* @throws ClientException
*/
public function __construct($publicKeyId)
{
parent::__construct();
$this->product('Sts');
$this->version('2015-04-01');
$this->action('GenerateSessionAccessKey');
$this->host('sts.ap-northeast-1.aliyuncs.com');
$this->scheme('https');
$this->regionId('cn-hangzhou');
$this->options['verify'] = false;
$this->options['query']['PublicKeyId'] = $publicKeyId;
$this->options['query']['DurationSeconds'] = Provider::DURATION_SECONDS;
}
}
<?php
namespace AlibabaCloud\Client\Credentials;
use Exception;
use AlibabaCloud\Client\SDK;
use AlibabaCloud\Client\Filter\CredentialFilter;
use AlibabaCloud\Client\Exception\ClientException;
/**
* Use the RSA key pair to complete the authentication (supported only on Japanese site)
*
* @package AlibabaCloud\Client\Credentials
*/
class RsaKeyPairCredential implements CredentialsInterface
{
/**
* @var string
*/
private $publicKeyId;
/**
* @var string
*/
private $privateKey;
/**
* RsaKeyPairCredential constructor.
*
* @param string $publicKeyId
* @param string $privateKeyFile
*
* @throws ClientException
*/
public function __construct($publicKeyId, $privateKeyFile)
{
CredentialFilter::publicKeyId($publicKeyId);
CredentialFilter::privateKeyFile($privateKeyFile);
$this->publicKeyId = $publicKeyId;
try {
$this->privateKey = file_get_contents($privateKeyFile);
} catch (Exception $exception) {
throw new ClientException(
$exception->getMessage(),
SDK::INVALID_CREDENTIAL
);
}
}
/**
* @return mixed
*/
public function getPrivateKey()
{
return $this->privateKey;
}
/**
* @return string
*/
public function getPublicKeyId()
{
return $this->publicKeyId;
}
/**
* @return string
*/
public function __toString()
{
return "publicKeyId#$this->publicKeyId";
}
}
<?php
namespace AlibabaCloud\Client\Credentials;
use AlibabaCloud\Client\Filter\CredentialFilter;
use AlibabaCloud\Client\Exception\ClientException;
/**
* Use the STS Token to complete the authentication.
*
* @package AlibabaCloud\Client\Credentials
*/
class StsCredential implements CredentialsInterface
{
/**
* @var string
*/
private $accessKeyId;
/**
* @var string
*/
private $accessKeySecret;
/**
* @var string
*/
private $securityToken;
/**
* StsCredential constructor.
*
* @param string $accessKeyId Access key ID
* @param string $accessKeySecret Access Key Secret
* @param string $securityToken Security Token
*
* @throws ClientException
*/
public function __construct($accessKeyId, $accessKeySecret, $securityToken = '')
{
CredentialFilter::AccessKey($accessKeyId, $accessKeySecret);
$this->accessKeyId = $accessKeyId;
$this->accessKeySecret = $accessKeySecret;
$this->securityToken = $securityToken;
}
/**
* @return string
*/
public function getAccessKeyId()
{
return $this->accessKeyId;
}
/**
* @return string
*/
public function getAccessKeySecret()
{
return $this->accessKeySecret;
}
/**
* @return string
*/
public function getSecurityToken()
{
return $this->securityToken;
}
/**
* @return string
*/
public function __toString()
{
return "$this->accessKeyId#$this->accessKeySecret#$this->securityToken";
}
}
<?php
namespace AlibabaCloud\Client;
use AlibabaCloud\Client\Result\Result;
use AlibabaCloud\Client\Clients\Client;
use AlibabaCloud\Client\Request\Request;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;
/**
* Class DefaultAcsClient
*
* @package AlibabaCloud
*
* @deprecated deprecated since version 2.0, Use AlibabaCloud instead.
* @codeCoverageIgnore
*/
class DefaultAcsClient
{
/**
* @var string
*/
public $randClientName;
/**
* DefaultAcsClient constructor.
*
* @param Client $client
*
* @throws ClientException
*/
public function __construct(Client $client)
{
$this->randClientName = \uniqid('', true);
$client->name($this->randClientName);
}
/**
* @param Request|Result $request
*
* @return Result|string
* @throws ClientException
* @throws ServerException
*/
public function getAcsResponse($request)
{
if ($request instanceof Result) {
return $request;
}
return $request->client($this->randClientName)->request();
}
}
<?php
namespace AlibabaCloud\Client;
/**
* Class Encode
*
* @package AlibabaCloud\Client
*/
class Encode
{
/**
* @var array
*/
private $data;
/**
* @param array $data
*
* @return static
*/
public static function create(array $data)
{
return new static($data);
}
/**
* Encode constructor.
*
* @param array $data
*/
private function __construct(array $data)
{
$this->data = $data;
}
/**
* @return bool|string
*/
public function toString()
{
$string = '';
foreach ($this->data as $key => $value) {
$encode = rawurlencode($value);
if ($encode === '') {
$string .= "$key&";
} else {
$string .= "$key=$encode&";
}
}
if (0 < count($this->data)) {
$string = substr($string, 0, -1);
}
return $string;
}
/**
* @return $this
*/
public function ksort()
{
ksort($this->data);
return $this;
}
}
<?php
namespace AlibabaCloud\Client\Exception;
use Exception;
use RuntimeException;
/**
* Class AlibabaCloudException
*
* @package AlibabaCloud\Client\Exception
*/
abstract class AlibabaCloudException extends Exception
{
/**
* @var string
*/
protected $errorCode;
/**
* @var string
*/
protected $errorMessage;
/**
* @return string
*/
public function getErrorCode()
{
return $this->errorCode;
}
/**
* @codeCoverageIgnore
* @deprecated
*/
public function setErrorCode()
{
throw new RuntimeException('deprecated since 2.0.');
}
/**
* @return string
*/
public function getErrorMessage()
{
return $this->errorMessage;
}
/**
* @codeCoverageIgnore
*
* @param $errorMessage
*
* @deprecated
*/
public function setErrorMessage($errorMessage)
{
$this->errorMessage = $errorMessage;
}
/**
* @codeCoverageIgnore
* @deprecated
*/
public function setErrorType()
{
}
}
<?php
namespace AlibabaCloud\Client\Exception;
use Exception;
use RuntimeException;
/**
* Class ClientException
*
* @package AlibabaCloud\Client\Exception
*/
class ClientException extends AlibabaCloudException
{
/**
* ClientException constructor.
*
* @param string $errorMessage
* @param string $errorCode
* @param Exception|null $previous
*/
public function __construct($errorMessage, $errorCode, $previous = null)
{
parent::__construct($errorMessage, 0, $previous);
$this->errorMessage = $errorMessage;
$this->errorCode = $errorCode;
}
/**
* @codeCoverageIgnore
* @deprecated
*/
public function getErrorType()
{
return 'Client';
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment