-
Notifications
You must be signed in to change notification settings - Fork 6
/
MsgBuilder.php
92 lines (83 loc) · 2.62 KB
/
MsgBuilder.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
//发送文字消息
function SendTextMsg($request,$msg){
return [
"event" => "SendTextMsg",
"robot_wxid" => $request['robot_wxid'],
"to_wxid" => $request['from_wxid'] ? $request['from_wxid'] : $request['final_from_wxid'],
"msg" => $msg,
];
}
//发送图片消息
function SendImageMsg($request,$url,$name){
return [
"event" => "SendImageMsg",
"robot_wxid" => $request['robot_wxid'],
"to_wxid" => $request['from_wxid'] ? $request['from_wxid'] : $request['final_from_wxid'],
"msg" => [
"url"=>$url,
"name"=>$name
]
];
}
//发送视频消息
function SendVideoMsg($request,$url,$name){
return [
"event" => "SendImageMsg",
"robot_wxid" => $request['robot_wxid'],
"to_wxid" => $request['from_wxid'] ? $request['from_wxid'] : $request['final_from_wxid'],
"msg" => [
"url"=>$url,
"name"=>$name
]
];
}
//发送文件消息
function SendFileMsg($request,$url,$name){
return [
"event" => "SendFileMsg",
"robot_wxid" => $request['robot_wxid'],
"to_wxid" => $request['from_wxid'] ? $request['from_wxid'] : $request['final_from_wxid'],
"msg" => [
"url"=>$url,
"name"=>$name
]
];
}
//发送动态表情消息
function SendEmojiMsg($request,$url,$name){
return [
"event" => "SendEmojiMsg",
"robot_wxid" => $request['robot_wxid'],
"to_wxid" => $request['from_wxid'] ? $request['from_wxid'] : $request['final_from_wxid'],
"msg" => [
"url"=>$url,
"name"=>$name
]
];
}
//发送分享卡片消息
function SendLinkMsg($request,$title,$text,$target_url,$pic_url,$icon_url){
$link = [
'title' => $title,
'text' => $text,
'target_url' => $target_url,
'pic_url' => $pic_url,
'icon_url' => $icon_url,
];
return [
"event" => "SendLinkMsg",
"robot_wxid" => $request['robot_wxid'],
"to_wxid" => $request['from_wxid'] ? $request['from_wxid'] : $request['final_from_wxid'],
"msg" => $link
];
}
//发送音乐分享
function SendMusicMsg($request,$name){
return [
"event" => "SendMusicMsg",
"robot_wxid" => $request['robot_wxid'],
"to_wxid" => $request['from_wxid'] ? $request['from_wxid'] : $request['final_from_wxid'],
"msg" => ['name'=>$name,'type'=>0],
];
}