private function processNewsResponses($token = '', $ids)
 {
     //图文回复
     $where = array('token' => $token, 'id' => array('in', implode(',', $ids)));
     $img_db = M('img');
     $img_items = $img_db->field(array('id', 'title', 'text' => 'description', 'pic' => 'picUrl', 'url', 'linktype', 'service'))->where($where)->limit(10)->select();
     if ($img_items) {
         foreach ($img_items as $key => $val) {
             $img_db->where(array('id' => $img_items[$key]['id']))->setInc('click');
             //linktype为info或者normal时应为正常逻辑,不是系统模块
             if (!empty($img_items[$key]['linktype']) && !in_array($img_items[$key]['linktype'], array('info', 'normal')) && !empty($img_items[$key]['service'])) {
                 $tags = explode('-', $img_items[$key]['service']);
                 $service_url = ServiceHelper::constructHyperLink($token, $tags[0], $tags[1], $tags[2]);
                 if (!empty($service_url)) {
                     if ($tags[0] != 'xiangce') {
                         //相册url不需要wechat_id, 否则token读取不正确
                         $service_url = $service_url . '&wecha_id=' . $this->fromWxId;
                     }
                     $img_items[$key]['url'] = $service_url;
                 }
             } else {
                 if (empty($img_items[$key]['url'])) {
                     $img_items[$key]['url'] = U('Wap/ImageDetail/index@' . C('wx_handler_server'), array('id' => $img_items[$key]['id'], 'template' => 'ktv_content', 'token' => $token));
                 } else {
                     if (strpos($img_items[$key]['url'], '?') && !strpos($img_items[$key]['url'], 'wecha_id=')) {
                         $img_items[$key]['url'] .= '&wecha_id=' . $this->fromWxId;
                         //为用户的链接加上wxid
                     }
                 }
             }
             $img_items[$key]['type'] = 'img';
         }
     }
     file_put_contents('/tmp/img_item', print_r($img_items, true));
     return $img_items;
 }
 private function getSystemServiceEntry($public_account, $service_tag)
 {
     if (empty($public_account) || empty($service_tag)) {
         return array();
     }
     $button = array();
     $tags = explode('-', $service_tag);
     if ($tags[0] == 'wifi' || $tags[0] == 'canyin' || $tags[0] == 'hotel' || $tags[0] == 'dingdan' || $tags[0] == 'dazhuanpan' || $tags[0] == 'guaguaka' || $tags[0] == 'youhuiquan' || $tags[0] == 'toupiao' || $tags[0] == 'huiyuanka') {
         $button['type'] = 'click';
         $button['key'] = urlencode($this->constructKeyword($this->token, $tags[0], $tags[1], $tags[2]));
     } else {
         if ($tags[0] == 'shouye') {
             if (empty($tags[1])) {
                 //这是首页,首页通过关键词进入
                 $button['type'] = 'click';
                 $button['key'] = urlencode($this->constructKeyword($this->token, $tags[0], $tags[1], $tags[2]));
             } else {
                 //栏目或者文章页
                 $button['type'] = 'view';
                 $button['url'] = ServiceHelper::constructHyperLink($this->token, $tags[0], $tags[1], $tags[2]);
             }
         } else {
             if ($tags[0] == 'car') {
                 if ($tags[1] == 'sales') {
                     $button['type'] = 'view';
                     $button['url'] = ServiceHelper::constructHyperLink($this->token, $tags[0], $tags[1], $tags[2]);
                 } else {
                     if ($tags[1] == 'car' || $tags[1] == 'drive' || $tags[1] == 'maintain' || $tags[1] == 'care') {
                         $button['type'] = 'click';
                         $button['key'] = urlencode($this->constructKeyword($this->token, $tags[0], $tags[1], $tags[2]));
                     }
                 }
             } else {
                 if ($public_account['is_authed'] == 1 && $public_account['type'] == 1) {
                     //认证过的服务号,url不带wechat_id
                     $button['type'] = 'view';
                     $button['url'] = ServiceHelper::constructHyperLink($this->token, $tags[0], $tags[1], $tags[2]);
                 } else {
                     //其他情况下用关键词实现
                     $button['type'] = 'click';
                     $button['key'] = urlencode($this->constructKeyword($this->token, $tags[0], $tags[1], $tags[2]));
                 }
             }
         }
     }
     return $button;
 }