3
This commit is contained in:
+29
-57
@@ -32,55 +32,51 @@ class Message extends SmallProgram
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $content
|
* @param string $content
|
||||||
* @return Result
|
* @return Message
|
||||||
* @throws \Exception
|
|
||||||
*/
|
*/
|
||||||
public function sendTextNews(string $content)
|
public function sendTextNews(string $content)
|
||||||
{
|
{
|
||||||
$this->msgData['msgtype'] = 'text';
|
$this->msgData['msgtype'] = 'text';
|
||||||
$this->msgData['text'] = ['content' => $content];
|
$this->msgData['text'] = ['content' => $content];
|
||||||
|
|
||||||
return $this->sendKefuMsg();
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $media_id
|
* @param string $media_id
|
||||||
* @return Result
|
* @return Message
|
||||||
* @throws \Exception
|
|
||||||
*/
|
*/
|
||||||
public function sendImageNews(string $media_id)
|
public function sendImageNews(string $media_id)
|
||||||
{
|
{
|
||||||
$this->msgData['msgtype'] = 'image';
|
$this->msgData['msgtype'] = 'image';
|
||||||
$this->msgData['image'] = ['media_id' => $media_id];
|
$this->msgData['image'] = ['media_id' => $media_id];
|
||||||
|
|
||||||
return $this->sendKefuMsg();
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $media_id
|
* @param string $media_id
|
||||||
* @return Result
|
* @return Message
|
||||||
* @throws \Exception
|
|
||||||
*/
|
*/
|
||||||
public function sendVoiceNews(string $media_id)
|
public function sendVoiceNews(string $media_id)
|
||||||
{
|
{
|
||||||
$this->msgData['msgtype'] = 'voice';
|
$this->msgData['msgtype'] = 'voice';
|
||||||
$this->msgData['voice'] = ['media_id' => $media_id];
|
$this->msgData['voice'] = ['media_id' => $media_id];
|
||||||
|
|
||||||
return $this->sendKefuMsg();
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $media_id
|
* @param string $media_id
|
||||||
* @return Result
|
* @return Message
|
||||||
* @throws \Exception
|
|
||||||
*/
|
*/
|
||||||
public function sendMpNewsNews(string $media_id)
|
public function sendMpNewsNews(string $media_id)
|
||||||
{
|
{
|
||||||
$this->msgData['msgtype'] = 'mpnews';
|
$this->msgData['msgtype'] = 'mpnews';
|
||||||
$this->msgData['mpnews'] = ['media_id' => $media_id];
|
$this->msgData['mpnews'] = ['media_id' => $media_id];
|
||||||
|
|
||||||
return $this->sendKefuMsg();
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -89,8 +85,7 @@ class Message extends SmallProgram
|
|||||||
* @param string $description
|
* @param string $description
|
||||||
* @param string $url
|
* @param string $url
|
||||||
* @param string $picurl
|
* @param string $picurl
|
||||||
* @return Result
|
* @return Message
|
||||||
* @throws \Exception
|
|
||||||
*/
|
*/
|
||||||
public function sendNewsNews(string $title, string $description, string $url, string $picurl)
|
public function sendNewsNews(string $title, string $description, string $url, string $picurl)
|
||||||
{
|
{
|
||||||
@@ -101,21 +96,20 @@ class Message extends SmallProgram
|
|||||||
'url' => $url,
|
'url' => $url,
|
||||||
'picurl' => $picurl
|
'picurl' => $picurl
|
||||||
]]];
|
]]];
|
||||||
return $this->sendKefuMsg();
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $title
|
* @param string $title
|
||||||
* @return Result
|
* @return Message
|
||||||
* @throws \Exception
|
|
||||||
*/
|
*/
|
||||||
public function sendCardNews(string $title)
|
public function sendCardNews(string $title)
|
||||||
{
|
{
|
||||||
$this->msgData['msgtype'] = 'wxcard';
|
$this->msgData['msgtype'] = 'wxcard';
|
||||||
$this->msgData['wxcard'] = ['card_id' => $title];
|
$this->msgData['wxcard'] = ['card_id' => $title];
|
||||||
|
|
||||||
return $this->sendKefuMsg();
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -124,8 +118,7 @@ class Message extends SmallProgram
|
|||||||
* @param string $thumb_media_id
|
* @param string $thumb_media_id
|
||||||
* @param string $title
|
* @param string $title
|
||||||
* @param string $description
|
* @param string $description
|
||||||
* @return Result
|
* @return Message
|
||||||
* @throws \Exception
|
|
||||||
*/
|
*/
|
||||||
public function sendVideoNews(string $media_id, string $thumb_media_id, string $title, string $description)
|
public function sendVideoNews(string $media_id, string $thumb_media_id, string $title, string $description)
|
||||||
{
|
{
|
||||||
@@ -136,7 +129,7 @@ class Message extends SmallProgram
|
|||||||
'title' => $title,
|
'title' => $title,
|
||||||
'description' => $description
|
'description' => $description
|
||||||
]];
|
]];
|
||||||
return $this->sendKefuMsg();
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -146,8 +139,7 @@ class Message extends SmallProgram
|
|||||||
* @param string $thumb_media_id
|
* @param string $thumb_media_id
|
||||||
* @param string $title
|
* @param string $title
|
||||||
* @param string $description
|
* @param string $description
|
||||||
* @return Result
|
* @return Message
|
||||||
* @throws \Exception
|
|
||||||
*/
|
*/
|
||||||
public function sendMusicNews(string $musicurl, string $hqmusicurl, string $thumb_media_id, string $title, string $description)
|
public function sendMusicNews(string $musicurl, string $hqmusicurl, string $thumb_media_id, string $title, string $description)
|
||||||
{
|
{
|
||||||
@@ -159,7 +151,7 @@ class Message extends SmallProgram
|
|||||||
'hqmusicurl' => $hqmusicurl,
|
'hqmusicurl' => $hqmusicurl,
|
||||||
'thumb_media_id' => $thumb_media_id
|
'thumb_media_id' => $thumb_media_id
|
||||||
];
|
];
|
||||||
return $this->sendKefuMsg();
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -167,7 +159,7 @@ class Message extends SmallProgram
|
|||||||
* @param string $head_content
|
* @param string $head_content
|
||||||
* @param string $tail_content
|
* @param string $tail_content
|
||||||
* @param array $menus
|
* @param array $menus
|
||||||
* @return Result
|
* @return Message
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function sendMenuNews(string $head_content, string $tail_content, array $menus = [])
|
public function sendMenuNews(string $head_content, string $tail_content, array $menus = [])
|
||||||
@@ -183,7 +175,7 @@ class Message extends SmallProgram
|
|||||||
foreach ($menus as $key => $val) {
|
foreach ($menus as $key => $val) {
|
||||||
$this->addNewsMenu($val['id'], $val['name']);
|
$this->addNewsMenu($val['id'], $val['name']);
|
||||||
}
|
}
|
||||||
return $this->sendKefuMsg();
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int $index = 0;
|
private int $index = 0;
|
||||||
@@ -203,12 +195,11 @@ class Message extends SmallProgram
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $title
|
* @param string $title
|
||||||
* @param $appid
|
* @param string $appid
|
||||||
* @param $pagepath
|
* @param string $pagepath
|
||||||
* @param $thumb_media_id
|
* @param string $thumb_media_id
|
||||||
* @return Result
|
* @return Message
|
||||||
* @throws \Exception
|
|
||||||
*/
|
*/
|
||||||
public function sendMiniprogrampageNews(string $title, string $appid, string $pagepath, string $thumb_media_id)
|
public function sendMiniprogrampageNews(string $title, string $appid, string $pagepath, string $thumb_media_id)
|
||||||
{
|
{
|
||||||
@@ -219,7 +210,7 @@ class Message extends SmallProgram
|
|||||||
'pagepath' => $pagepath,
|
'pagepath' => $pagepath,
|
||||||
'thumb_media_id' => $thumb_media_id,
|
'thumb_media_id' => $thumb_media_id,
|
||||||
];
|
];
|
||||||
return $this->sendKefuMsg();
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -268,28 +259,10 @@ class Message extends SmallProgram
|
|||||||
return $data->getData();
|
return $data->getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $mime
|
* @return array
|
||||||
* @throws \Exception
|
|
||||||
*/
|
*/
|
||||||
private function checkExtinfo($mime)
|
|
||||||
{
|
|
||||||
switch (strtolower($mime)) {
|
|
||||||
case 'image/bmp':
|
|
||||||
case 'image/png':
|
|
||||||
case 'image/jpeg':
|
|
||||||
case 'image/jpg':
|
|
||||||
case 'image/gif':
|
|
||||||
case 'mp3/wma/wav/amr':
|
|
||||||
case 'mp4';
|
|
||||||
case 'jpg';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new \Exception('不支持的文件格式');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function getContents()
|
public function getContents()
|
||||||
{
|
{
|
||||||
return $this->msgData;
|
return $this->msgData;
|
||||||
@@ -297,7 +270,6 @@ class Message extends SmallProgram
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $data
|
|
||||||
* @return Result
|
* @return Result
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user