本文为您介绍了PHP调用QueryMessage查看短信状态。
请求参数
名称 | 类型 | 是否必选 | 示例值 | 描述 |
---|---|---|---|---|
MessageId | String | 是 | 100***03003003 | 短信发送ID。 |
返回数据
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
ResponseCode | String | OK | 短信提交的状态。 |
ResponseDescription | String | The SMS Send Request was accepted | 短信提交状态的详细描述。 |
To | String | 658***7810 | 发送号码。 |
Status | Number | 1 | 短信的发送状态:
|
ErrorCode | String | DELIVERED | 短信的发送状态码。 |
ErrorDescription | String | success | 短信发送状态码的详细描述。 |
Message | String | Hello! | 短信内容。 |
SendDate | String | Mon, 24 Dec 2018 16:58:22 +0800 | 短信转发给运营商的时间。 |
ReceiveDate | String | Mon, 24 Dec 2018 16:58:22 +0800 | 短信收到运营商回执的时间。 |
NumberDetail | String | 号码的详细属性。 | |
└Country | String | Hongkong, China | 号码所属国家。 |
└Region | String | HongKong | Number Region。 |
└Carrier | String | CMI | 号码所属的运营商网络。 |
引入阿里云核心包
Composer安装,点击查看下载地址。
调用示例
注意事项如下:
- regionId必须为ap-southeast-1,请勿修改。
- product必须为Dysmsapi,请勿修改。
- host必须为dysmsapi.ap-southeast-1.aliyuncs.com,请勿修改。
- version必须为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;
}