Exemple #1
0
<?php

require_once 'functions.php';
//开始监听 app1 - 供应商查询
if (isset($_GET["msg_signature"]) && isset($_GET["timestamp"]) && isset($_GET["nonce"])) {
    $wx = new weixin();
    $xmlstr = $wx->get_msg('1');
    $res_xmlstr = simplexml_load_string($xmlstr);
    $fromUserName = $res_xmlstr->FromUserName;
    $createTime = $res_xmlstr->CreateTime;
    $msgType = $res_xmlstr->MsgType;
    $agentID = $res_xmlstr->AgentID;
    if ($msgType == "event") {
        $event = $res_xmlstr->Event;
        $eventKey = $res_xmlstr->EventKey;
        //$msgId = $res_xmlstr->MsgId;
    }
    if ($event == "click" && !empty($eventKey)) {
        $con = mysql_connect("127.0.0.1", "root", "root");
        mysql_select_db("wx", $con);
        $sql = "UPDATE customer_tbl SET language = '{$eventKey}' WHERE user_id = '{$fromUserName}'";
        mysql_query($sql, $con);
        //update
        mysql_close($con);
    }
}
// $obj -> send_img("plustree",
// "1U5VsijM4djNnRhyOOpuyy1XsuQaXDwxjztQ9gnnq43i-D3b_cqh9R4B4lJTMutXR"
// );
Exemple #2
0
<?php

require_once 'functions.php';
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
//开始监听 app2 - app test
if (isset($_GET["msg_signature"]) && isset($_GET["timestamp"]) && isset($_GET["nonce"])) {
    $wx = new weixin();
    $xmlstr = $wx->get_msg('2');
    $res_xmlstr = simplexml_load_string($xmlstr);
    $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') {
Exemple #3
0
<?php

require_once 'functions.php';
//开始监听 app3 - 朗姿供应链微妙平台 用户维护
if (isset($_GET["msg_signature"]) && isset($_GET["timestamp"]) && isset($_GET["nonce"])) {
    $wx = new weixin();
    $xmlstr = $wx->get_msg('3');
    $res_xmlstr = simplexml_load_string($xmlstr);
    $fromUserName = $res_xmlstr->FromUserName;
    $createTime = $res_xmlstr->CreateTime;
    $msgType = $res_xmlstr->MsgType;
    $agentID = $res_xmlstr->AgentID;
    if ($msgType == "event") {
        $event = $res_xmlstr->Event;
        $eventKey = $res_xmlstr->EventKey;
        //$msgId = $res_xmlstr->MsgId;
    }
    //接收手机发送图片
    if ($msgType == "image") {
        $picUrl = $res_xmlstr->PicUrl;
        $mediaId = $res_xmlstr->MediaId;
        //$msgId = $res_xmlstr->MsgId;
        $fp = fopen('log.txt', 'w');
        fwrite($fp, $picUrl);
        fclose($fp);
    }
    //进入应用事件响应并消息去重
    if ($event == 'enter_agent' && $eventKey == '') {
        $con = mysql_connect("127.0.0.1", "root", "root");
        mysql_select_db("wx", $con);
        $sql = "SELECT count(1) from customer_tbl WHERE user_id = '{$fromUserName}' AND create_time= '{$createTime}'";