阿里云开发文档: https://help.aliyun.com/document_detail/112186.html?spm=a2c4g.11186623.6.658.72165f30sifEbv
1、申请 AccessKey
2、安装sdk
composer require alibabacloud/client
3、使用OpenAPI Explorer来生成相关API的Demo,并应用在您的项目中。
4、如,短信Demo:
<?phpuse 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.mdAlibabaCloud::accessKeyClient('<accessKeyId>', '<accessSecret>')->regionId('cn-hangzhou')->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' => ['RegionId' => "cn-hangzhou",'PhoneNumbers' => $phone,'SignName' => $signName,'TemplateCode' => $template_code,'TemplateParam' => $templateParam],])->request();print_r($result->toArray());} catch (ClientException $e) {echo $e->getErrorMessage() . PHP_EOL;} catch (ServerException $e) {echo $e->getErrorMessage() . PHP_EOL;}
