# 消息實體
消息實體提供消息對象的生成與約束,用于公眾號被動回復消息接口,消息實體包含以下 6 種類型:
- 文本消息
- 圖像消息
- 語音消息
- 視頻消息
- 音樂消息
- 圖文消息
http://mp.weixin.qq.com/wiki/14/89b871b5466b19b3efa4ada8e577d45e.html
## 一、文本消息
```php
use Thenbsp\Wechat\Message\Entity\Text;
$options = array(
'ToUserName' => 'toUser',
'FromUserName' => 'fromUser',
'CreateTime' => 'CreateTime',
'Content' => '你好'
);
$entity = new Text($options);
```
## 二、圖像消息
```php
use Thenbsp\Wechat\Message\Entity\Image;
$options = array(
'ToUserName' => 'toUser',
'FromUserName' => 'fromUser',
'CreateTime' => 'CreateTime',
'Image' => array(
'MediaId' => 'Image MediaId'
)
);
$entity = new Image($options);
```
## 三、語音消息
```php
use Thenbsp\Wechat\Message\Entity\Voice;
$options = array(
'ToUserName' => 'toUser',
'FromUserName' => 'fromUser',
'CreateTime' => 'CreateTime',
'Voice' => array(
'MediaId' => 'Voice MediaId'
)
);
$entity = new Voice($options);
```
## 四、視頻消息
```php
use Thenbsp\Wechat\Message\Entity\Video;
$options = array(
'ToUserName' => 'toUser',
'FromUserName' => 'fromUser',
'CreateTime' => 'CreateTime',
'Video' => array(
'MediaId' => 'Video MediaId',
'Title' => 'Video Title',
'Description' => 'Video Description'
)
);
$entity = new Video($options);
```
## 五、音樂消息
```php
use Thenbsp\Wechat\Message\Entity\Music;
$options = array(
'ToUserName' => 'toUser',
'FromUserName' => 'fromUser',
'CreateTime' => 'CreateTime',
'Music' => array(
'Title' => 'Music Title',
'Description' => 'Music Description',
'MusicUrl' => 'Music MusicUrl',
'HQMusicUrl' => 'Music HQMusicUrl',
'ThumbMediaId' => 'Music ThumbMediaId'
)
);
$entity = new Music($options);
```
## 六、圖文消息
```php
use Thenbsp\Wechat\Message\Entity\News;
$options = array(
'ToUserName' => 'toUser',
'FromUserName' => 'fromUser',
'CreateTime' => 'CreateTime',
'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'
)
)
)
);
$entity = new News($options);
```
## 查看消息實體參數
```php
var_dump($entity->getOptions());
```
## 查看消息數據
```php
var_dump($entity->getData());
```
## 輸出消息實體
```php
$entity->send();
```