예제 #1
0
파일: index2.php 프로젝트: wuya1986/php
 $fromUserName = $res_xmlstr->FromUserName;
 $createTime = $res_xmlstr->CreateTime;
 $msgType = $res_xmlstr->MsgType;
 $agentID = $res_xmlstr->AgentID;
 if (!$redis->exists('timestamp')) {
     $redis->set('timestamp', (string) $fromUserName . (string) $createTime);
 }
 if ($redis->exists('timestamp')) {
     if ((string) $fromUserName . (string) $createTime != $redis->get('timestamp')) {
         $redis->set('timestamp', (string) $fromUserName . (string) $createTime);
         if ($msgType == "text" || $msgType == "image") {
             $content = $res_xmlstr->Content;
             $content = trim($content);
             if ($content == '1' || $content == '2') {
                 $redis->set('type', (string) $fromUserName . (string) $content);
                 $wx->log($redis->get('type'));
             }
             //"#1 开启上传模式"的逻辑
             if (($msgType == "text" || $msgType == "image") && $redis->get('type') == (string) $fromUserName . '1') {
                 //提示用户输入图片名称
                 if ($content == '1') {
                     $wx->send_msg(array('userid' => (string) $fromUserName, 'appid' => (string) $agentID, 'msg' => '请您输入要上传的图片名称'));
                 }
                 //储存供应商号码
                 if ($msgType == "text" && $content != '1') {
                     //服务器缓存$content值
                     $redis->set("content", (string) $content);
                     $wx->send_msg(array('userid' => (string) $fromUserName, 'appid' => (string) $agentID, 'msg' => '请您拍照上传'));
                     //$wx -> log($redis->get('content'));
                 }
                 //接收手机发送图片