阿里云开发文档: https://help.aliyun.com/document_detail/112186.html?spm=a2c4g.11186623.6.658.72165f30sifEbv

    1、申请 AccessKey
    2、安装sdk

    1. composer require alibabacloud/client

    3、使用OpenAPI Explorer来生成相关API的Demo,并应用在您的项目中。
    4、如,短信Demo:

    1. <?php
    2. use AlibabaCloud\Client\AlibabaCloud;
    3. use AlibabaCloud\Client\Exception\ClientException;
    4. use AlibabaCloud\Client\Exception\ServerException;
    5. // Download:https://github.com/aliyun/openapi-sdk-php
    6. // Usage:https://github.com/aliyun/openapi-sdk-php/blob/master/README.md
    7. AlibabaCloud::accessKeyClient('<accessKeyId>', '<accessSecret>')
    8. ->regionId('cn-hangzhou')
    9. ->asDefaultClient();
    10. try {
    11. $result = AlibabaCloud::rpc()
    12. ->product('Dysmsapi')
    13. // ->scheme('https') // https | http
    14. ->version('2017-05-25')
    15. ->action('SendSms')
    16. ->method('POST')
    17. ->host('dysmsapi.aliyuncs.com')
    18. ->options([
    19. 'query' => [
    20. 'RegionId' => "cn-hangzhou",
    21. 'PhoneNumbers' => $phone,
    22. 'SignName' => $signName,
    23. 'TemplateCode' => $template_code,
    24. 'TemplateParam' => $templateParam
    25. ],
    26. ])
    27. ->request();
    28. print_r($result->toArray());
    29. } catch (ClientException $e) {
    30. echo $e->getErrorMessage() . PHP_EOL;
    31. } catch (ServerException $e) {
    32. echo $e->getErrorMessage() . PHP_EOL;
    33. }