[
"type" => "服务号",
"media_id" => "kd_b598cb7474d8"
],
"gh_43ba50c16fba" => [
"type" => "服务号",
"media_id" => "kd_fuwuhaoqunfa"
],
"gh_6a208af55d22" => [
"type" => "服务号",
"media_id" => "kd_fuwuhaoqunfa"
],
// "gh_c94c95866ca5"=>[
// "type"=>"服务号",
// "media_id"=>"kd_fuwuhaoqunfa"
// ],
// "gh_8ad154093fc4"=>[
// "type"=>"订阅号",
// "media_id"=>"kd_dingyuequnfa"
// ],
"gh_67bc8afa5ed9" => [
"type" => "订阅号",
"media_id" => "kd_dingyuequnfa"
],
"gh_4167f0d2c89d" => [
"type" => "订阅号",
"media_id" => "kd_dingyuequnfa"
],
"gh_04406cb77cf5" => [
"type" => "订阅号",
"media_id" => "kd_dingyuequnfa"
],
"gh_dbbe2df61ccf" => [
"type" => "订阅号",
"media_id" => "kd_dingyuequnfa"
],
];
private function getUrl()
{
return $this->url . $this->medias[$this->publicId]['media_id'];
}
private function getContent()
{
switch ($this->sex) {
case "男":
return "欢迎报名本期72小时恋爱活动☞【脱单合伙人】☜
双十一除了是购物节还是脱单节,所以?在场的小哥哥有没有愿意和我一起脱单呀?
【点此一起脱单】
【点此继续单身】
点击下方蓝字查看本周活动优化
↓ ↓
本周活动优化详情";
case "女":
return "今日惊喜:101款小哥哥正在“预售”,赶快领取你的心动选手吧!
【点此领取】
【残忍拒绝】
点击下方蓝字查看本周活动优化
↓ ↓
本周活动优化详情";
case "未知":
return "欢迎报名本期72小时恋爱活动☞【脱单合伙人】☜
【点此领取小哥哥】
【点此领取小姐姐】
点击下方蓝字查看本周活动优化
↓ ↓
本周活动优化详情";
break;
}
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$option = $this->choice('请选择执行操作', [
'preview' => '预览',
'tag' => '男女标签发送',
'hebeikeda' => '河北科大的标签发送',
'batch' => '所有用户发送',
'all' => '全部公众号发送',
]);
switch ($option) {
case "preview":
$this->publicId = $this->ask("公众号ID");
$this->sex = $this->choice('请选择性别', [
'1' => '男',
'2' => '女',
'0' => '未知',
]);
$this->preview();
break;
case "tag":
$this->publicId = $this->ask("公众号ID");
$this->sex = $this->choice('请选择性别', [
'1' => '男',
'2' => '女',
'0' => '未知',
]);
$this->sendTag();
break;
case "hebeikeda":
$this->publicId = "gh_b598cb7474d8";
$this->sex = $this->choice('请选择标签', [
'1' => '男',
'2' => '女',
'0' => '未知',
]);
$this->sendHeBeiTag();
break;
case "batch":
$this->publicId = $this->ask("公众号ID");
$this->sex = $this->choice('请选择性别', [
'1' => '男',
'2' => '女',
'0' => '未知',
]);
$this->batch();
break;
case "all":
if ($this->confirm('确认发送周二群发功能??????')) {
$this->sendAll();
}
break;
}
}
public function preview()
{
$result = \WeChat::Mass($this->publicId)->preview("CCAV---BOSS", "text", [
'content' => $this->getContent()
]);
dd($result);
}
public function sendHeBeiTag()
{
switch ($this->sex) {
case "男":
$tagId = \WeChat::Tags($this->publicId)->get("河北科大-男");
if (!$tagId) {
dd("没有此标签");
}
dump($tagId);
$result = \WeChat::Mass($this->publicId)->sendTag(
$tagId,
'text',
['content' => $this->getContent()]
);
dump($result);
break;
case "女":
$tagId = \WeChat::Tags($this->publicId)->get("河北科大-女");
if (!$tagId) {
dd("没有此标签");
}
dump($tagId);
$result = \WeChat::Mass($this->publicId)->sendTag(
$tagId,
'text',
['content' => $this->getContent()]
);
dump($result);
break;
case "未知":
$tagId = \WeChat::Tags($this->publicId)->get("河北科大-无");
if (!$tagId) {
dd("没有此标签");
}
dump($tagId);
$result = \WeChat::Mass($this->publicId)->sendTag(
$tagId,
'text',
['content' => $this->getContent()]
);
dump($result);
break;
}
}
public function sendTag()
{
switch ($this->sex) {
case "男":
$tagId = \WeChat::Tags($this->publicId)->get("性别-男");
if (!$tagId) {
dd("没有此标签");
}
$result = \WeChat::Mass($this->publicId)->sendTag(
$tagId,
'text',
['content' => $this->getContent()]
);
dump($tagId);
dump($result);
break;
case "女":
$tagId = \WeChat::Tags($this->publicId)->get("性别-女");
if (!$tagId) {
dd("没有此标签");
}
$result = \WeChat::Mass($this->publicId)->sendTag(
$tagId,
'text',
['content' => $this->getContent()]
);
dump($tagId);
dump($result);
break;
case "未知":
$tagId = \WeChat::Tags($this->publicId)->get("性别-未知");
if (!$tagId) {
dd("没有此标签");
}
$result = \WeChat::Mass($this->publicId)->sendTag(
$tagId,
'text',
['content' => $this->getContent()]
);
dump($tagId);
dump($result);
break;
}
}
public function batch()
{
$result = \WeChat::Mass($this->publicId)
->sendAll(
'text',
['content' => $this->getContent()]
);
dump($result);
}
public function sendAll()
{
foreach ($this->medias as $publicId => $media) {
$this->publicId = $publicId;
switch ($media['type']) {
case "服务号":
$this->sex = "男";
dump($this->publicId . "------------" . $this->sex);
$this->sendTag();
$this->sex = "女";
dump($this->publicId . "------------" . $this->sex);
$this->sendTag();
$this->sex = "未知";
dump($this->publicId . "------------" . $this->sex);
$this->sendTag();
break;
case "订阅号":
$this->sex = "未知";
dump($this->publicId . "------------" . "all");
$this->batch();
break;
}
dump($this->publicId);
dump("end");
}
}
}