This topic provides a comprehensive guide on how to utilize Alibaba Cloud SMS SDK for PHP. By incorporating this SDK as a dependency in your application, you can easily integrate the SendMessageToGlobe operation, enabling you to send SMS messages to various regions around the world, excluding the Chinese mainland.
Usage notes
You must set the regionId parameter to ap-southeast-1.
You must set the product parameter to Dysmsapi.
You must set the host parameter to dysmsapi.ap-southeast-1.aliyuncs.com.
You must set the version parameter to 2018-05-01.
Sample code
<?php
use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;
// Download:https://github.com/aliyun/openapi-sdk-php-client
// Usage:https://github.com/aliyun/openapi-sdk-php-client/blob/master/README-zh-CN.md
AlibabaCloud::accessKeyClient('<accessKeyId>', '<accessSecret>')
->regionId('ap-southeast-1')
->asGlobalClient();
try {
$result = AlibabaCloud::rpcRequest()
->product('Dysmsapi')
->host('dysmsapi.ap-southeast-1.aliyuncs.com')
->version('2018-05-01')
->action('SendMessageToGlobe')
->method('POST')
->options([
'query' => [
"To" => "62123****8901",
"From" => "1234567890",
"Message" => "have a test.",
],
])
->request();
print_r($result->toArray());