|
@@ -50,12 +50,12 @@ class VPush
|
|
|
|
|
|
/**
|
|
|
* 设置推送消息
|
|
|
- * @param $title
|
|
|
- * @param $content
|
|
|
- * @param $url
|
|
|
- * @param $regId
|
|
|
+ * @param $title
|
|
|
+ * @param $content
|
|
|
+ * @param $url
|
|
|
+ * @param array $regId
|
|
|
*/
|
|
|
- public function setPushData($title, $content, $url, $regId)
|
|
|
+ public function setPushData($title, $content, $url, $regId = [])
|
|
|
{
|
|
|
// 赋值
|
|
|
$this->_title = $title;
|
|
@@ -104,6 +104,9 @@ class VPush
|
|
|
if (!$this->_taskId) {
|
|
|
throw new InvalidArgumentException('VIVO推送必须要设置taskId');
|
|
|
}
|
|
|
+ if (!$this->_regId) {
|
|
|
+ throw new InvalidArgumentException('VIVO推送必须要设置regId');
|
|
|
+ }
|
|
|
|
|
|
$data = [
|
|
|
'regIds' => $this->_regId,
|
|
@@ -122,7 +125,7 @@ class VPush
|
|
|
public function sendAll()
|
|
|
{
|
|
|
// 校验参数
|
|
|
- $this->checkSendAllParam();
|
|
|
+ $this->checkParam();
|
|
|
$data = [
|
|
|
'requestId' => Utils::randCode(),
|
|
|
'title' => $this->_title,
|
|
@@ -203,46 +206,6 @@ class VPush
|
|
|
if (!$this->_timeToLive) {
|
|
|
throw new InvalidArgumentException('VIVO推送必须要设置timeToLive');
|
|
|
}
|
|
|
- if (!$this->_regId) {
|
|
|
- throw new InvalidArgumentException('VIVO推送必须要设置regId');
|
|
|
- }
|
|
|
- return $this;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 校验参数
|
|
|
- * @param false $sendAll
|
|
|
- * @return $this
|
|
|
- * @throws GuzzleException
|
|
|
- */
|
|
|
- private function checkSendAllParam()
|
|
|
- {
|
|
|
- // 授权token校验
|
|
|
- if (!$this->_accessToken) {
|
|
|
- $this->getAccessToken();
|
|
|
- }
|
|
|
-
|
|
|
- if (!$this->_appId) {
|
|
|
- throw new InvalidArgumentException('VIVO推送必须要设置appId');
|
|
|
- }
|
|
|
- if (!$this->_appKey) {
|
|
|
- throw new InvalidArgumentException('VIVO推送必须要设置appKey');
|
|
|
- }
|
|
|
- if (!$this->_appSecret) {
|
|
|
- throw new InvalidArgumentException('VIVO推送必须要设置appSecret');
|
|
|
- }
|
|
|
- if (!$this->_accessToken) {
|
|
|
- throw new InvalidArgumentException('VIVO推送必须要设置AccessToken');
|
|
|
- }
|
|
|
- if (!$this->_title) {
|
|
|
- throw new InvalidArgumentException('VIVO推送必须要设置title');
|
|
|
- }
|
|
|
- if (!$this->_content) {
|
|
|
- throw new InvalidArgumentException('VIVO推送必须要设置content');
|
|
|
- }
|
|
|
- if (!$this->_timeToLive) {
|
|
|
- throw new InvalidArgumentException('VIVO推送必须要设置timeToLive');
|
|
|
- }
|
|
|
return $this;
|
|
|
}
|
|
|
|