sendCustomNotice() - 發送客服消息
### 說明
```
sendCustomNotice($data)
```
### 參數
- **$data** array() 要發送的數據請求包(結構如下)
發送文本:
```
array(
'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4' //粉絲openid
'msgtype': 'text', //消息類型
'text': array(
'content': 'hello world' //文本消息內容
)
)
```
發送圖片:
```
array(
'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4' //粉絲openid
'msgtype': 'image', //消息類型
'image': array(
'media_id': 'oR5OU2VN0aCr9Kkg4lalkhvPRRd4AVl662uabDZrKBY' //文本消息內容
)
)
```
發送語音:
```
array(
'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4' //粉絲openid
'msgtype': 'voice', //消息類型
'voice': array(
'media_id': 'oR5OU2VN0aCr9Kkg4lalkhvPRRd4AVl662uabDZrKBY' //素材mediaid
)
)
```
發送視頻:
```
array(
'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4' //粉絲openid
'msgtype': 'video', //消息類型
'video': array(
'title':'我的視頻',
'description':'視頻描述',
'media_id': 'oR5OU2VN0aCr9Kkg4lalkhvPRRd4AVl662uabDZrKBY' //素材mediaid
'thumb_media_id':'oR5OU2VN0aCr9Kkg4lalkpzzdOc628ATnCmlfZdgJt4'
)
)
```
發送音樂:
```
array(
'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4' //粉絲openid
'msgtype': 'music', //消息類型
'music': array(
'title':'我的音樂', //音樂消息的標題
'description':'音樂描述', //音樂消息的描述
'musicurl': 'MUSIC_URL', //音樂鏈接
'hqmusicurl':'HQ_MUSIC_URL', //高品質音樂鏈接,wifi環境優先使用該鏈接播放音樂
'thumb_media_id': 'oR5OU2VN0aCr9Kkg4lalkpzzdOc628ATnCmlfZdgJt4'//縮略圖
)
)
```
發送圖文消息(點擊跳轉到外鏈),圖文消息條數限制在8條以內,注意,如果圖文數超過8,則將返回錯誤:
```
array(
'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4' //粉絲openid
'msgtype': 'news', //消息類型
'news': array(
array(
'title':'Happy Day',
'description':'Is Really A Happy Day',
'url': 'URL',
'picurl':'PIC_URL',
),
array(
'title':'Happy Day',
'description':'Is Really A Happy Day',
'url': 'URL',
'picurl':'PIC_URL',
)
)
)
```
發送圖文消息(點擊跳轉到圖文消息頁面),圖文消息條數限制在8條以內,注意,如果圖文數超過8,則將返回錯誤:
```
array(
'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4' //粉絲openid
'msgtype': 'mpnews', //消息類型
'mpnews': array(
'media_id':'oR5OU2VN0aCr9Kkg4lalki6pnvzxCGJEWX-x_8yU58Y',
)
)
```
發送卡券:
```
array(
'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4', //粉絲openid
'msgtype': 'wxcard', //消息類型
'wxcard': array(
'card_id': 'ah34j567d7kf8l4hje2ljle'
)
)
```
發送小程序卡片(要求小程序與公眾號已關聯):
```
array(
'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4', //粉絲openid
'msgtype': 'miniprogrampage', //消息類型
'miniprogrampage': array(
'title': 'title', //小程序卡片的標題
'appid': 'appid', //小程序的appid,要求小程序的appid需要與公眾號有關聯關系
'pagepath': 'pagepath', //小程序的頁面路徑,跟app.json對齊,支持參數,比如pages/index/index?foo=bar
'thumb_media_id': 'oR5OU2VN0aCr9Kkg4lalkhvPRRd4AVl662uabDZrKBY' //小程序卡片圖片的媒體ID,小程序卡片圖片建議大小為520*416
)
)
```
### 返回值
#### error
可用is_error判斷,詳見《錯誤處理》
#### success
返回boolean值:true
### 示例
```
$custom = array(
'msgtype' => 'text',
'text' => array('content' => urlencode('歡迎您再次訂購!')),
'touser' => 'oPUOlw7yvucjUrZhzG6gd8VdILa4',
);
$account_api = WeAccount::create();
$result = $account_api->sendCustomNotice($custom);
print_r($result);
```