1、删除禁用函数
在禁用函数中删除或 php.ini 中查找 disable_functions 删除后面的函数即可
putenv() 、 pcntl_signal() 、 proc_open()
2、安装composer
安装
curl -sS https://getcomposer.org/installer | php
更新
composer self-update
3、移动文件方便全局调用
mv composer.phar /usr/bin/composer
4、更换国内源
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
5、查看安装信息
composer -v
6、安装SDK
composer require alibabacloud/client
7、发送短信
<?php use AlibabaCloud\Client\AlibabaCloud; use AlibabaCloud\Client\Exception\ClientException; use AlibabaCloud\Client\Exception\ServerException; // Download:https://github.com/aliyun/openapi-sdk-php // Usage:https://github.com/aliyun/openapi-sdk-php/blob/master/README.md AlibabaCloud::accessKeyClient('<accessKeyId>', '<accessSecret>') ->regionId('ap-northeast-1') ->asDefaultClient(); try { $result = AlibabaCloud::rpc() ->product('Dysmsapi') // ->scheme('https') // https | http ->version('2017-05-25') ->action('SendSms') ->method('POST') ->host('dysmsapi.aliyuncs.com') ->options([ 'query' => [ 'PhoneNumbers' => "1503871****", 'SignName' => "阿里大于测试专用", 'TemplateCode' => "SMS_209335004", 'TemplateParam' => "{\"code\":\"1111\"}", ], ]) ->request(); print_r($result->toArray()); } catch (ClientException $e) { echo $e->getErrorMessage() . PHP_EOL; } catch (ServerException $e) { echo $e->getErrorMessage() . PHP_EOL; }