This topic describes how to use SMS SDK for PHP to call the QueryMessage operation. This API operation allows you to query the statuses of text messages.
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
MessageId | String | Yes | 100***03003003 | The ID of the text message. |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
ResponseCode | String | OK | The status that indicates whether the message sending request was submitted. |
ResponseDescription | String | The SMS Send Request was accepted | The detailed description of the status that indicates whether the message sending request was submitted. |
To | String | 658***7810 | The mobile phone number that received the text message. |
Status | Number | 1 | The status that indicates whether the text message was sent.
|
ErrorCode | String | DELIVERED | The status code that indicates whether the text message was sent. |
ErrorDescription | String | success | The description of the status code that indicates whether the text message was sent. |
Message | String | Hello! | The content of the text message. |
SendDate | String | Mon, 24 Dec 2018 16:58:22 +0800 | The time when the text message was sent to the carrier. |
ReceiveDate | String | Mon, 24 Dec 2018 16:58:22 +0800 | The time when the delivery receipt was received from the carrier. |
NumberDetail | String | The details of the mobile phone number. | |
└Country | String | Hongkong, China | The country to which the mobile phone number belongs. |
└Region | String | HongKong | The region to which the mobile phone number belongs. |
└Carrier | String | CMI | The carrier that provides the mobile phone number. |
Install the core library of Alibaba Cloud SDK for PHP
Click Alibaba Cloud SDK for PHP to download the core library of Alibaba Cloud SDK for PHP by using the Composer dependency manager.
Sample requests
Take note of the following information:
- 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.
<?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-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('QueryMessage')
->method('POST')
->options([
'query' => [
"MessageId" => "140101545641902498",
],
])
->request();
print_r($result->toArray());
} catch (ClientException $e) {
echo $e->getErrorMessage() . PHP_EOL;
} catch (ServerException $e) {
echo $e->getErrorMessage() . PHP_EOL;
}