function tp10weixinadd(){ $postStr = file_get_contents("php://input"); $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); $fromUsername = $postObj->FromUserName;//用户信息 $toUsername = $postObj->ToUserName;//公众号原始id $keyword = trim($postObj->Content);//关键词 $keyword = trim(str_replace('投票','',get_keyword($keyword))); $keyword = str_replace(' ','',str_replace('+','',str_replace('#','',str_replace('#','',$keyword)))); if(empty($keyword)){echo '请按格式输入投票内容';exit();} $time = time(); $token=$_GET['token'];//公众号在pigcms里面的token //下面是根据粉丝输入的关键词进行回复,回复以微信接口的标准xml回复,请看这里http://mp.weixin.qq.com/wiki/index.php?title=%E5%8F%91%E9%80%81%E8%A2%AB%E5%8A%A8%E5%93%8D%E5%BA%94%E6%B6%88%E6%81%AF $textTpl = "<xml>".time()." "; $M_lp_toupiao_player = M("Lp_toupiao_player"); $where['siteid'] = get_siteid(); $where['id'] = $keyword; $where['tid'] = 10; $where['islock'] =0; $data['row'] = $M_lp_toupiao_player->where($where)->find(); if(empty($data['row']) || empty($keyword)){ $textTpl .= ""; } $Lp_toupiao_num = M("Lp_toupiao_num"); $w['pid'] = $keyword; $w['name'] = "$fromUsername"; $w['siteid'] = get_siteid(); $w['tid'] = 10; $isRow = $Lp_toupiao_num->where($w)->find(); if(!empty($isRow) || empty($w['name'])){ $textTpl .= " "; } $w1['name'] = "$fromUsername"; $w1['pid'] = $keyword; $w1['siteid'] = get_siteid(); $w1['tid'] = 10; $w1['source'] = '微信'; $w1['addtime'] = time(); $Lp_toupiao_num1 = M("Lp_toupiao_num"); $add = $Lp_toupiao_num1->add($w1); if($add){ $M_lp_toupiao_player->where($where)->setInc('pcnum'); $textTpl .= " 1 "; $textTpl .= " "; } $textTpl .= ""; echo $textTpl; }- "; $textTpl .= "
<![CDATA["."投票成功!寻找全城“最甜蜜恋人”,我们是".$data['row']['id']."号甜蜜恋人".$data['row']['cname']."&".$data['row']['lpname']."]]>
声明:此文系舞林cuzn(www.wulinlw.org)原创稿件,转载请保留版权