### sendCustomNotice() -
### 說明
~~~
sendCustomNotice($data)
~~~
發送客服消息
### 參數
* $data 要發送的數據請求包(結構如下)
* touser 粉絲openid
* msgtype
* text 文本消息
* image 圖片消息
* voice 語音消息
* video 視頻消息
* music 音樂消息
* news 圖文消息
* wxcard 卡劵消息
* miniprogrampage 小程序卡片消息
* 下面分類型說明發送內容具體參數
#### 文本消息
~~~
array(
'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4'
'msgtype': 'text',
'text': array(
'content': 'hello world' //文本消息內容
)
)
~~~
#### 圖片消息
~~~
array(
'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4'
'msgtype': 'image',
'image': array(
'media_id': 'oR5OU2VN0aCr9Kkg4lalkhvPRRd4AVl662uabDZrKBY' //素材ID
)
)
~~~
#### 語音消息
~~~
array(
'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4'
'msgtype': 'voice',
'voice': array(
'media_id': 'oR5OU2VN0aCr9Kkg4lalkhvPRRd4AVl662uabDZrKBY' //素材ID
)
)
~~~
#### 視頻消息
~~~
array(
'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4'
'msgtype': 'video',
'video': array(
'title':'我的視頻',
'description':'視頻描述',
'media_id': 'oR5OU2VN0aCr9Kkg4lalkhvPRRd4AVl662uabDZrKBY' //素材ID
'thumb_media_id':'oR5OU2VN0aCr9Kkg4lalkpzzdOc628ATnCmlfZdgJt4' //縮略圖素材ID
)
)
~~~
#### 音樂消息
~~~
array(
'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4'
'msgtype': 'music',
'music': array(
'title':'我的音樂', //音樂消息的標題
'description':'音樂描述', //音樂消息的描述
'musicurl': 'http://we7.com/1.mp3', //音樂鏈接
'hqmusicurl':'http://we7.com/1.mp3', //高品質音樂鏈接,wifi環境優先使用該鏈接播放音樂
'thumb_media_id': 'oR5OU2VN0aCr9Kkg4lalkpzzdOc628ATnCmlfZdgJt4' //縮略圖素材ID
)
)
~~~
#### 圖文消息
發送圖文消息(點擊跳轉到外鏈),圖文消息條數限制在8條以內,注意,如果圖文數超過8,則將返回錯誤:
~~~
array(
'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4'
'msgtype': 'news',
'news': array(
array(
'title':'Happy Day',
'description':'Is Really A Happy Day',
'url': 'http://we7.cc/',
'picurl':'http://we7.cc/1.jpg',
),
array(
'title':'Happy Day',
'description':'Is Really A Happy Day',
'url': 'http://we7.cc/',
'picurl':'http://we7.cc/1.jpg',
)
)
)
~~~
發送圖文消息(點擊跳轉到圖文消息頁面),圖文消息條數限制在8條以內,注意,如果圖文數超過8,則將返回錯誤:
~~~
array(
'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4'
'msgtype': 'mpnews',
'mpnews': array(
'media_id':'oR5OU2VN0aCr9Kkg4lalki6pnvzxCGJEWX-x_8yU58Y', //圖文消息素材ID
)
)
~~~
#### 卡券消息
~~~
array(
'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4',
'msgtype': 'wxcard',
'wxcard': array(
'card_id': 'ah34j567d7kf8l4hje2ljle' //卡券ID
)
)
~~~
#### 小程序卡片消息
發送小程序卡片(要求小程序與公眾號已關聯):
~~~
array(
'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4',
'msgtype': 'miniprogrampage',
'miniprogrampage': array(
'title': 'title', //小程序卡片的標題
'appid': 'appid', //小程序的appid,要求小程序的appid需要與公眾號有關聯關系
'pagepath': 'pages/index/index?foo=bar', //小程序的頁面路徑,跟app.json中一樣
'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);
~~~