getRevSceneId() public method

获取二维码的场景值
public getRevSceneId ( )
Ejemplo n.º 1
0
$options = array('token' => 'scubike', 'appid' => 'YOUR_APPID', 'appsecret' => 'YOUR_APPSECRET');
$systemError = "系统错误,请稍后再试";
$apiUrl = "http://1.scubiketest.sinaapp.com";
$apiSuffix = "php";
$w = new Wechat($options);
$w->valid();
$type = $w->getRev()->getRevType();
switch ($type) {
    case Wechat::MSGTYPE_TEXT:
        $w->text("感谢您的留言,稍后回复您!")->reply();
        break;
    case Wechat::MSGTYPE_EVENT:
        $result = $w->getRevEvent();
        switch ($result['event']) {
            case 'subscribe':
                if ($w->getRevSceneId()) {
                    //0.将该扫描事件写入数据库,扫描时间,用户id,
                    $postScanurl = $apiUrl . "/postScan." . $apiSuffix;
                    //写入扫描时间的api @post
                    $param = array('wechatId' => $w->getRevFrom(), 'createAt' => $w->getRevCtime(), 'stationId' => $w->getRevSceneId(), 'status' => 0);
                    http_post($postScanurl, $param);
                    //1.检查数据库是否有该用户
                    $getUserinfoUrl = $apiUrl . "/getUserinfo." . $apiSuffix . "?wechatId=" . $w->getRevFrom();
                    $userinfo = json_decode(http_get($getUserinfoUrl));
                    //2.如果有,查询该用户是否有借车行为
                    if ($userinfo->status == "0") {
                        //@get
                        $userLendUrl = $apiUrl . "/userLend." . $apiSuffix . "?userId=" . $userinfo->info->userId . "&lendStatus=0";
                        $userLend = json_decode(http_get($userLendUrl));
                        //3.如果2的结果是有,提示:XX请在3分钟内点击下方还车按钮进行还车
                        if ($userLend->status == "0") {
Ejemplo n.º 2
0
         if ($userInfo['pic']) {
             $weObj->text("成功修改证件照片!")->reply();
         } else {
             $weObj->text("成功录入证件照片!\n再次提交即可修改")->reply();
         }
     }
     $db->disconnect();
     break;
 case Wechat::MSGTYPE_TEXT:
     $weObj->text("你好,欢迎来到imall 公益电商平台 和" . WX_TITLE . " 校园公共自行车服务!\n\n<a href='http://www.imall365.org'>点此开始imall公益电商之旅!</a>\n<a href='" . $authURI . "'>点此开始你的" . WX_TITLE . "!</a>")->reply();
     break;
 case Wechat::MSGTYPE_EVENT:
     $e = $weObj->getRevEvent();
     switch ($e['event']) {
         case Wechat::EVENT_SUBSCRIBE:
             $scan = $weObj->getRevSceneId();
             if (ereg("^[0-9]+\$", $scan)) {
                 $weObj->text("欢迎新用户来到imall 公益电商平台 和" . WX_TITLE . " 校园公共自行车服务!\n\n在借车前请先提交认证信息,等我们确认您的身份后即可享受校园公共自行车服务了~\n\n<a href='http://www.imall365.org'>点此开始imall公益电商之旅!</a>\n<a href='" . $authURI . "'>点此开始你的" . WX_TITLE . "!</a>")->reply();
             } else {
                 if (substr($scan, 0, 5) == 'prizea') {
                     $redirectURI3 = urlencode("http://" . WX_URL . "/main.php?a=prize");
                     $authURI3 = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" . WX_APPID . "&redirect_uri=" . $redirectURI3 . "&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
                     $weObj->text("欢迎新用户来到imall 公益电商平台 和" . WX_TITLE . " 校园公共自行车服务!\n\n在借车前请先提交认证信息,等我们确认您的身份后即可享受校园公共自行车服务了~\n\n<a href='http://www.imall365.org'>点此开始imall公益电商之旅!</a>\n<a href='" . $authURI . "'>点此开始你的" . WX_TITLE . "!</a>\n\n" . "<a href='{$authURI3}'>点此抽奖~</a>")->reply();
                 } else {
                     $weObj->text("欢迎新用户来到imall 公益电商平台 和" . WX_TITLE . " 校园公共自行车服务!\n\n在借车前请先提交认证信息,等我们确认您的身份后即可享受校园公共自行车服务了~\n\n<a href='http://www.imall365.org'>点此开始imall公益电商之旅!</a>\n<a href='" . $authURI . "'>点此开始你的" . WX_TITLE . "!</a>")->reply();
                     //$weObj->text ( "你好,欢迎来到imall 公益电商平台 和" . WX_TITLE . " 校园公共自行车服务!\n\n<a href='http://www.imall365.org'>点此开始imall公益电商之旅!</a>\n<a href='" . $authURI . "'>点此开始你的" . WX_TITLE . "!</a>" )->reply ();
                 }
             }
             break;
         case Wechat::EVENT_SCAN:
             $scan = $weObj->getRevSceneId();
Ejemplo n.º 3
0
             //取消上网权限
             $sql = "select * from " . WEIXIN_TABLE . "\n                    WHERE `fromUserName` = '{$fromUserName}'";
             $res = $mysql::query($sql, 'all');
             if (is_array($res) && count($res) > 0) {
                 //删除数据
                 $sql = "DELETE FROM " . WEIXIN_TABLE . "\n                        WHERE `fromUserName` = '{$fromUserName}'";
                 $mysql::query($sql);
                 foreach ($res as $key => $value) {
                     UniFi::sendUnauthorization($value['Mac_ID']);
                     sleep(2);
                 }
             }
         } else {
             if ($event == 'scan') {
                 $ticket = $weObj->getRevTicket();
                 $scene_id = $weObj->getRevSceneId();
                 $sql = "select * from " . WEIXIN_TABLE . " WHERE `scene_id` = '{$scene_id}'";
                 $res = $mysql::query($sql, 'all');
                 $Mac_ID = $res[0]['Mac_ID'];
                 $site = $res[0]['site'];
                 UniFi::set_site($site);
                 UniFi::sendAuthorization($Mac_ID, WIFI_EXPIRED_TIME);
                 $sql = "update " . WEIXIN_TABLE . "\n                    set `fromUserName` = '{$fromUserName}',\n                        `ticket` = 'authorized'\n                    where `scene_id` = '{$scene_id}'";
                 $mysql::query($sql);
                 sleep(2);
                 $weObj->text('Welcome to the Free WiFi')->reply();
             }
         }
     }
     break;
 case Wechat::MSGTYPE_IMAGE: