1.文本接口
接口開發步驟:
// 接收用戶消息類型
$msgType = $postObj->MsgType;
2>在接收消息是對$MsgType進行判斷
if ($msgType == 'text') {
# code...
// 判斷用戶發送關鍵詞是否爲空
if(!empty( $keyword ))
{
// 回覆類型 如果爲text 代表文本
$msgType = "text";
// 回覆內容
$contentStr = "你發送的是文本消息!";
// 格式化字符串
$resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
// 把XML返回給手機端
echo $resultStr;
}