-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
101 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,67 @@ | ||
## 友盟消息推送 | ||
开发阶段 | ||
|
||
### 安装 | ||
|
||
```text | ||
composer require wujie/youmeng | ||
``` | ||
|
||
### demo | ||
|
||
#### 设置配置文件 | ||
```php | ||
<?php | ||
$config = new \Youmeng\Config\Config([ | ||
'appKey' => '', | ||
'masterSecret' => '', | ||
'retryNum' => 1,//失败重试次数 | ||
'production_mode' => 'true' | ||
]); | ||
``` | ||
|
||
##### 功能 | ||
1. 用户单个或者批量推送 | ||
#### 推送 | ||
|
||
```php | ||
<?php | ||
|
||
$comMessage = (new \Youmeng\Push\CommonMessage()) | ||
->setTitle("") | ||
->setDesc("") | ||
->setMessageType(\Youmeng\Push\Message::TYPE_CUSTOMIZE_CAST) | ||
->setMessageData($alidateId) | ||
->setOtherParams([]); | ||
|
||
$sendRequest = new \Youmeng\Request\SendRequest($config); | ||
$data = $sendRequest->androidMessage($signId, $comMessage); | ||
|
||
``` | ||
|
||
|
||
#### 查询推送状态 | ||
|
||
```php | ||
|
||
<?php | ||
(new \Youmeng\Request\StatusRequest($config))->status($taskId); | ||
|
||
``` | ||
|
||
#### 取消定时任务 | ||
|
||
```php | ||
<?php | ||
(new \Youmeng\Request\CancelRequest($config))->cancel($taskId); | ||
|
||
``` | ||
|
||
|
||
#### 上传任务 | ||
|
||
```php | ||
|
||
<?php | ||
|
||
(new \Youmeng\Request\UpdateRequest($config))->update($content); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
|
||
namespace Youmeng\Request; | ||
|
||
|
||
class CancelRequest extends BaseRequest | ||
{ | ||
|
||
/** | ||
* 取消定时任务 | ||
* @param string $taskId | ||
* @return array | ||
*/ | ||
public function cancel(string $taskId) | ||
{ | ||
$this->requestModel->post('api/cancel', ['task_id', $taskId]); | ||
return [$this->requestModel->isOk(), $this->requestModel->getData()]; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
|
||
namespace Youmeng\Request; | ||
|
||
|
||
class UpdateRequest extends BaseRequest | ||
{ | ||
|
||
/** | ||
* 文件上传 | ||
* @param string $content | ||
* @return array | ||
*/ | ||
public function update(string $content) | ||
{ | ||
$this->requestModel->post('update', ['content' => $content]); | ||
return [$this->requestModel->isOk(), $this->requestModel->getData()]; | ||
} | ||
|
||
} |