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