forked from thenbsp/wechat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
message-entity.php
112 lines (96 loc) · 2.95 KB
/
message-entity.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
require './example.php';
use Thenbsp\Wechat\Message\Entity\News;
use Thenbsp\Wechat\Message\Entity\Text;
use Thenbsp\Wechat\Message\Entity\Image;
use Thenbsp\Wechat\Message\Entity\Voice;
use Thenbsp\Wechat\Message\Entity\Video;
use Thenbsp\Wechat\Message\Entity\Music;
// 文本消息
$text = new Text(array(
'ToUserName' => 'toUser',
'FromUserName' => 'fromUser',
'CreateTime' => 'CreateTime',
'Content' => '你好'
));
print_r($text->getOptions());
// 图像消息
$image = new Image(array(
'ToUserName' => 'toUser',
'FromUserName' => 'fromUser',
'CreateTime' => 'CreateTime',
'Image' => array(
'MediaId' => 'Image MediaId'
)
));
print_r($image->getOptions());
// 语音消息
$voice = new Voice(array(
'ToUserName' => 'toUser',
'FromUserName' => 'fromUser',
'CreateTime' => 'CreateTime',
'Voice' => array(
'MediaId' => 'Voice MediaId'
)
));
print_r($voice->getOptions());
// 视频消息
$video = new Video(array(
'ToUserName' => 'toUser',
'FromUserName' => 'fromUser',
'CreateTime' => 'CreateTime',
'Video' => array(
'MediaId' => 'Video MediaId',
'Title' => 'Video Title',
'Description' => 'Video Description'
)
));
print_r($video->getOptions());
// 音乐消息
$music = new Music(array(
'ToUserName' => 'toUser',
'FromUserName' => 'fromUser',
'CreateTime' => 'CreateTime',
'Music' => array(
'Title' => 'Music Title',
'Description' => 'Music Description',
'MusicUrl' => 'Music MusicUrl',
'HQMusicUrl' => 'Music HQMusicUrl',
'ThumbMediaId' => 'Music ThumbMediaId'
)
));
print_r($music->getOptions());
// 图文消息
$news = new News(array(
'ToUserName' => 'toUser',
'FromUserName' => 'fromUser',
'CreateTime' => 'CreateTime',
// 'ArticleCount' => 2,
'Articles' => array(
'item' => array(
array(
'Title' => 'News 1 Title',
'Description' => 'News 1 Description',
'PicUrl' => 'News 1 Title',
'Url' => 'News 1 Title',
),
array(
'Title' => 'News 2 Title',
'Description' => 'News 2 Description',
'PicUrl' => 'News 2 Title',
'Url' => 'News 2 Title'
),
array(
'Title' => 'News 3 Title',
'Description' => 'News 3 Description',
'PicUrl' => 'News 3 Title',
'Url' => 'News 3 Title'
)
)
)
));
print_r($news->getOptions());
/**
* 最后输出 XMl 可以使用 getData 方法
*/
// var_dump($news->getData());