3
This commit is contained in:
+38
-36
@@ -38,7 +38,7 @@ class Message extends SmallProgram
|
|||||||
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->sendKefuMsg();
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ class Message extends SmallProgram
|
|||||||
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->sendKefuMsg();
|
||||||
}
|
}
|
||||||
@@ -65,7 +65,7 @@ class Message extends SmallProgram
|
|||||||
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->sendKefuMsg();
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,7 @@ class Message extends SmallProgram
|
|||||||
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->sendKefuMsg();
|
||||||
}
|
}
|
||||||
@@ -95,11 +95,12 @@ class Message extends SmallProgram
|
|||||||
public function sendNewsNews(string $title, string $description, string $url, string $picurl)
|
public function sendNewsNews(string $title, string $description, string $url, string $picurl)
|
||||||
{
|
{
|
||||||
$this->msgData['msgtype'] = 'news';
|
$this->msgData['msgtype'] = 'news';
|
||||||
$this->msgData['news[articles][0][title]'] = $title;
|
$this->msgData['news'] = ['articles' => [[
|
||||||
$this->msgData['news[articles][0][description]'] = $description;
|
'title' => $title,
|
||||||
$this->msgData['news[articles][0][url]'] = $url;
|
'description' => $description,
|
||||||
$this->msgData['news[articles][0][picurl]'] = $picurl;
|
'url' => $url,
|
||||||
|
'picurl' => $picurl
|
||||||
|
]]];
|
||||||
return $this->sendKefuMsg();
|
return $this->sendKefuMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +113,7 @@ class Message extends SmallProgram
|
|||||||
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->sendKefuMsg();
|
||||||
}
|
}
|
||||||
@@ -129,11 +130,12 @@ class Message extends SmallProgram
|
|||||||
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)
|
||||||
{
|
{
|
||||||
$this->msgData['msgtype'] = 'video';
|
$this->msgData['msgtype'] = 'video';
|
||||||
$this->msgData['video[media_id]'] = $media_id;
|
$this->msgData['video'] = ['media_id' => [
|
||||||
$this->msgData['video[thumb_media_id]'] = $thumb_media_id;
|
'media_id' => $media_id,
|
||||||
$this->msgData['video[title]'] = $title;
|
'thumb_media_id' => $thumb_media_id,
|
||||||
$this->msgData['video[description]'] = $description;
|
'title' => $title,
|
||||||
|
'description' => $description
|
||||||
|
]];
|
||||||
return $this->sendKefuMsg();
|
return $this->sendKefuMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,12 +152,13 @@ class Message extends SmallProgram
|
|||||||
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)
|
||||||
{
|
{
|
||||||
$this->msgData['msgtype'] = 'music';
|
$this->msgData['msgtype'] = 'music';
|
||||||
$this->msgData['music[title]'] = $title;
|
$this->msgData['music'] = [
|
||||||
$this->msgData['music[description]'] = $description;
|
'title' => $title,
|
||||||
$this->msgData['music[musicurl]'] = $musicurl;
|
'description' => $description,
|
||||||
$this->msgData['music[hqmusicurl]'] = $hqmusicurl;
|
'musicurl' => $musicurl,
|
||||||
$this->msgData['music[thumb_media_id]'] = $thumb_media_id;
|
'hqmusicurl' => $hqmusicurl,
|
||||||
|
'thumb_media_id' => $thumb_media_id
|
||||||
|
];
|
||||||
return $this->sendKefuMsg();
|
return $this->sendKefuMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,21 +173,20 @@ class Message extends SmallProgram
|
|||||||
public function sendMenuNews(string $head_content, string $tail_content, array $menus = [])
|
public function sendMenuNews(string $head_content, string $tail_content, array $menus = [])
|
||||||
{
|
{
|
||||||
$this->msgData['msgtype'] = 'msgmenu';
|
$this->msgData['msgtype'] = 'msgmenu';
|
||||||
$this->msgData['msgmenu[head_content]'] = $head_content;
|
$this->msgData['msgmenu'] = [
|
||||||
$this->msgData['msgmenu[tail_content]'] = $tail_content;
|
'head_content' => $head_content,
|
||||||
|
'tail_content' => $tail_content,
|
||||||
|
];
|
||||||
if (empty($menus) || !is_array($menus) || count($menus) < 2) {
|
if (empty($menus) || !is_array($menus) || count($menus) < 2) {
|
||||||
throw new \Exception('菜单选项必须有2个');
|
throw new \Exception('菜单选项必须有2个');
|
||||||
}
|
}
|
||||||
|
|
||||||
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->sendKefuMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
private $index = 0;
|
private int $index = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $id
|
* @param $id
|
||||||
@@ -193,11 +195,10 @@ class Message extends SmallProgram
|
|||||||
*/
|
*/
|
||||||
public function addNewsMenu($id, $menuName)
|
public function addNewsMenu($id, $menuName)
|
||||||
{
|
{
|
||||||
$this->msgData['msgmenu[list][' . $this->index . '][id]'] = $id;
|
$lists['id'] = $id;
|
||||||
$this->msgData['msgmenu[list][' . $this->index . '][content]'] = $menuName;
|
$lists['content'] = $menuName;
|
||||||
|
$this->msgData['msgmenu']['list'][$this->index] = $lists;
|
||||||
++$this->index;
|
++$this->index;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,11 +213,12 @@ class Message extends SmallProgram
|
|||||||
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)
|
||||||
{
|
{
|
||||||
$this->msgData['msgtype'] = 'msgmenu';
|
$this->msgData['msgtype'] = 'msgmenu';
|
||||||
$this->msgData['miniprogrampage[title]'] = $title;
|
$this->msgData['miniprogrampage'] = [
|
||||||
$this->msgData['miniprogrampage[appid]'] = $appid;
|
'title' => $title,
|
||||||
$this->msgData['miniprogrampage[pagepath]'] = $pagepath;
|
'appid' => $appid,
|
||||||
$this->msgData['miniprogrampage[thumb_media_id]'] = $thumb_media_id;
|
'pagepath' => $pagepath,
|
||||||
|
'thumb_media_id' => $thumb_media_id,
|
||||||
|
];
|
||||||
return $this->sendKefuMsg();
|
return $this->sendKefuMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user