function handleSubscribe($postObj) { $uid = 0; $params = array(array("" . $postObj->FromUserName, SQLSRV_PARAM_IN), array("" . $postObj->ToUserName, SQLSRV_PARAM_IN), array($uid, SQLSRV_PARAM_INOUT)); $sp = "{call app_subscrible(?,?,?)}"; sp_execute($sp, $params); // //关注时通过微信号获取用户基本信息 if ($user = get_unionid_userinfo(db_get_token_ticket(CFG_APPID, CFG_SECRET)["token"], $postObj->FromUserName)) { $params = array(array("" . $user["openid"], SQLSRV_PARAM_IN), array("" . $user["nickname"], SQLSRV_PARAM_IN), array("" . $user["province"], SQLSRV_PARAM_IN), array("" . $user["city"], SQLSRV_PARAM_IN), array("" . $user["country"], SQLSRV_PARAM_IN), array(intval($user["sex"]), SQLSRV_PARAM_IN), array("" . $user["headimgurl"], SQLSRV_PARAM_IN)); sp_execute("{call app_set_userinfo(?,?,?,?,?,?,?)}", $params); } else { db_log("获取用户信息失败!"); } //用户扫描带场景值二维码 $cids = ""; if (strstr($postObj->EventKey, "qrscene_")) { $cids = substr($postObj->EventKey, strlen("qrscene_")); $cid = str2num(canteenid_content, $cids); } else { $cid = 0; } // $sp = "{call app_user_add_canteen(?,?)}"; $params = array(array($uid, SQLSRV_PARAM_IN), array($cid, SQLSRV_PARAM_IN)); $rs = sp_execute($sp, $params); // response_canteen_welcome($postObj, $cids, $rs[0]["cname"], $rs[0]["picurl"], $rs[0]["newsid"]); }
/** * 处理关注微信号 * @param $postObj */ function handleSubscribe($postObj) { $sub_scan_flag = 0; $uid = 0; $params = array(array("" . $postObj->FromUserName, SQLSRV_PARAM_IN), array("" . $postObj->ToUserName, SQLSRV_PARAM_IN), array($uid, SQLSRV_PARAM_OUT)); sp_execute("{call app_subscrible(?,?,?)}", $params); //关注时通过微信号获取用户基本信息 if ($user = get_unionid_userinfo(db_get_token_ticket(CFG_APPID, CFG_SECRET)["token"], $postObj->FromUserName)) { $params = array(array("" . $user["openid"], SQLSRV_PARAM_IN), array("" . $user["nickname"], SQLSRV_PARAM_IN), array("" . $user["province"], SQLSRV_PARAM_IN), array("" . $user["city"], SQLSRV_PARAM_IN), array("" . $user["country"], SQLSRV_PARAM_IN), array(intval($user["sex"]), SQLSRV_PARAM_IN), array("" . $user["headimgurl"], SQLSRV_PARAM_IN)); sp_execute("{call app_set_userinfo(?,?,?,?,?,?,?)}", $params); } else { db_log("获取用户信息失败!"); } //用户扫描带场景值二维码 if (strstr($postObj->EventKey, "qrscene_")) { $sub_scan_flag = 1; $scenestr = substr($postObj->EventKey, strlen("qrscene_")); $scenestr = explode("-", $scenestr); $uid_from = str2num(CFG_ID_USER, $scenestr[0]); $cid = str2num(CFG_ID_CAR, $scenestr[1]); log_file("sub, uid_from:{$uid_from}, cid:{$cid}, uid:{$uid}"); //共享车辆 $params = array(array($cid, SQLSRV_PARAM_IN), array($uid_from, SQLSRV_PARAM_IN), array($uid, SQLSRV_PARAM_IN)); sp_execute("{call app_share_car(?,?,?)}", $params); } else { log_file("场景值信息有误"); } if ($sub_scan_flag == 0) { //准备图文消息 $newsContent = array("title" => "您好,欢迎关注金创想!", "description" => "点击查看详情", "picUrl" => CFG_HTTP . "images/jcx0826.png", "url" => CFG_HTTP . "mobile/car_list.php"); response_news($postObj, $newsContent); } else { //查询分享发起人信息 $params = array(array($uid_from, SQLSRV_PARAM_IN), array("", SQLSRV_PARAM_IN)); $rs = sp_execute("{call app_get_userinfo(?,?)}", $params); //准备图文消息 $newsContent = array("title" => "好友" . $rs[0]["nickname"] . "的车辆信息", "description" => "点击查看详情", "picUrl" => CFG_HTTP . CFG_CAR_DEFAULT, "url" => CFG_HTTP . "mobile/car_list.php"); response_news($postObj, $newsContent); } }