From 3d931fb54a0bd1d433fa26024dd0bb63979de81c Mon Sep 17 00:00:00 2001 From: Helperhaps Date: Tue, 9 Jan 2018 02:39:14 +0000 Subject: [PATCH] add status message --- doc/api.md | 10 ++++++++++ src/JPush/ReportPayload.php | 13 +++++++++++++ src/JPush/version.php | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/doc/api.md b/doc/api.md index 69a7e01..82020ce 100644 --- a/doc/api.md +++ b/doc/api.md @@ -307,6 +307,16 @@ $report->getReceived('msg_id'); $report->getReceived(['msg_id1', 'msg_id2']); ``` +#### 送达状态查询 + +```php +$report->getMessageStatus('msg_id0', 'rid0') +# OR +$report->getMessageStatus('msg_id0', ['rid0', 'rid1']) +#OR +$report->getMessageStatus('msg_id0', ['rid0', 'rid1'], '2017-12-21') +``` + #### 获取消息统计 ```php diff --git a/src/JPush/ReportPayload.php b/src/JPush/ReportPayload.php index 98bec77..3f1133c 100644 --- a/src/JPush/ReportPayload.php +++ b/src/JPush/ReportPayload.php @@ -31,6 +31,19 @@ public function getReceived($msgIds) { return Http::get($this->client, $url); } + public function getMessageStatus($msgId, $rids, $data = null) { + $url = $this->client->makeURL('report') . ' status/message'; + $registrationIds = is_array($rids) ? $rids : array($rids); + $body = [ + 'msg_id' => $msgId, + 'registration_ids' => $registrationIds + ]; + if (!is_null($data)) { + $body['data'] = $data; + } + return Http::post($this->client, $url, $body); + } + public function getMessages($msgIds) { $queryParams = '?msg_ids='; if (is_array($msgIds) && !empty($msgIds)) { diff --git a/src/JPush/version.php b/src/JPush/version.php index af2056c..3b1bc65 100644 --- a/src/JPush/version.php +++ b/src/JPush/version.php @@ -1,4 +1,4 @@