Skip to content

Commit

Permalink
Update Push.php
Browse files Browse the repository at this point in the history
添加厂商通道
  • Loading branch information
619096932 authored Jan 20, 2021
1 parent a0babd1 commit 70a842c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Push.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Push
* @return array
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function toSingleCid(array $cid, NotificationMessage $message)
public function toSingleCid(array $cid, NotificationMessage $message, $push_channel)
{
$data = (new HttpRequest([
'verify' => false
Expand All @@ -33,7 +33,8 @@ public function toSingleCid(array $cid, NotificationMessage $message)
'audience' => [
'cid' => $cid
],
'push_message' => $message->toArray()
'push_message' => $message->toArray(),
'push_channel' => $push_channel
])->send();
if (!(isset($data['msg']) && $data['msg'] === 'success' && isset($data['code']) && $data['code'] === 0)) {
throw new \Exception(isset($data['msg']) ? $data['msg'] : '接口错误');
Expand All @@ -47,7 +48,7 @@ public function toSingleCid(array $cid, NotificationMessage $message)
* @return array
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function toAll(NotificationMessage $message)
public function toAll(NotificationMessage $message, $push_channel)
{
return (new HttpRequest([
'verify' => false
Expand All @@ -58,7 +59,8 @@ public function toAll(NotificationMessage $message)
'ttl' => 3600000
],
'audience' => 'all',
'push_message' => $message->toArray()
'push_message' => $message->toArray(),
'push_channel' => $push_channel
])->send();
}

Expand All @@ -69,7 +71,7 @@ public function toAll(NotificationMessage $message)
* @return array
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function toSingleAlias(array $alias, NotificationMessage $message)
public function toSingleAlias(array $alias, NotificationMessage $message, $push_channel)
{
return (new HttpRequest([
'verify' => false
Expand All @@ -78,7 +80,8 @@ public function toSingleAlias(array $alias, NotificationMessage $message)
'alias' => $alias
],
'request_id' => uniqid('', true),
'push_message' => $message->toArray()
'push_message' => $message->toArray(),
'push_channel' => $push_channel
])->send();
}
}

0 comments on commit 70a842c

Please sign in to comment.