<?php /** * wechat php test */ include 'weixinlib/textmsg.php'; include 'weixinlib/secretmsg.php'; $wechatObj = new wechatCallbackapiTest(); $wechatObj->responseMsg('<xml><ToUserName><![CDATA[gh_3b9f2b7cbeb1]]></ToUserName> <FromUserName><![CDATA[onJi-jkBg94_yLkoQLmlVFDTPqfk]]></FromUserName> <CreateTime>1364050029</CreateTime> <MsgType><![CDATA[text]]></MsgType> <Content><![CDATA[kk]]></Content> <MsgId>5858550264762860409</MsgId> </xml>'); class wechatCallbackapiTest { public function valid() { $echoStr = $_GET['echostr']; //valid signature , option if ($this->checkSignature()) { echo $echoStr; $this->responseMsg(); exit; } } public function responseMsg($postStr) { //get post data, May be due to the different environments // $postStr = $GLOBALS['HTTP_RAW_POST_DATA']; //extract post data
<?php //功能是提供大转盘的兑换,目前是加积分2,且只有一个奖项 $wechatObj = new wechatCallbackapiTest(); $wechatObj->responseMsg(); class wechatCallbackapiTest { public function responseMsg() { $keyword = trim($_GET['quan']); $fromUsername = $_GET['name']; require_once 'conn.php'; preg_match_all("/[A-Za-z0-9]/", $keyword, $match01); $select = $match01[0]; foreach ($select as $val) { $abc .= $val; } $item = substr($abc, 4, 2); //创建时间记录 $t = time(); $datestamp = date("Y-m-d H:i:s", $t); //更新历史列表 $checklist = mysql_fetch_array(mysql_query("select * from shop_history where secret = '{$abc}'")); if (!empty($checklist) && $checklist['used'] == "NO") { mysql_query("UPDATE shop_history SET used = 'YES', usedtime='{$datestamp}' WHERE secret = '{$abc}'"); //获取积分 $result_jifen = mysql_fetch_array(mysql_query("select * from jifen where user like '%{$fromUsername}%'")); if ($item == "04") { $score_changed = $result_jifen['score'] + 4; //增加积分量 } elseif ($item == "01") {
public function index() { /*{{{*/ $wechatObj = new wechatCallbackapiTest(); if (isset($_GET['echostr'])) { $wechatObj->valid(); } else { $wechatObj->responseMsg(); } }