private function getQrPicUrl($ecid, $sceneId) { $m = M("Company_info"); $opt['company_ecid'] = $ecid; $token = $m->where($opt)->find(); //如果接口信息不完整,直接返回 if ($token['weixin_AppId'] == '' || $token['weixin_AppSecret'] == '') { return; } $weObj = new \Org\Weixin\Wechat(); if ($weObj->checkAuth($token['weixin_AppId'], $token['weixin_AppSecret'])) { $qrCode = $weObj->getQRCode($sceneId, 0); if ($qrCode) { return $weObj->getQRUrl($qrCode['ticket']); } } }
private function getQrPicUrl($ecid, $sceneId) { $token = $this->getAppToken($ecid); //如果接口信息不完整,直接返回 if ($token['weixin_AppId'] == '' || $token['weixin_AppSecret'] == '') { return; } $weObj = new \Org\Weixin\Wechat(); if ($weObj->checkAuth($token['weixin_AppId'], $token['weixin_AppSecret'])) { $qrCode = $weObj->getQRCode($sceneId, 1); if ($qrCode) { return $weObj->getQRUrl($qrCode['ticket']); } } }
public function sendCustomMessage() { $token = $this->getAppToken(session($this->_userCfg['ECID'])); //如果接口信息不完整,直接返回 if ($token['weixin_AppId'] == '' || $token['weixin_AppSecret'] == '') { $this->ajaxReturn(Error::ERROR_MENU_TOKEN_EMPTY, Error::getErrMsg(Error::ERROR_MENU_TOKEN_EMPTY), 0); } $data['touser'] = I('post.touser'); $data['msgtype'] = I('post.msgtype'); $data['text'] = I('post.text', '', ''); $weObj = new \Org\Weixin\Wechat(); if ($weObj->checkAuth($token['weixin_AppId'], $token['weixin_AppSecret'])) { $result = $weObj->sendCustomMessage($data); if ($result['errcode'] == 0) { $opt['ecid'] = session($this->_userCfg['ECID']); $opt['openId'] = $data['touser']; $opt['responseType'] = 'text'; $opt['content'] = $data['text']['content']; $opt['time'] = date("Y-m-d H:i:s"); M('Company_response')->add($opt); } $this->ajaxReturn($result); } }
public function releaseMenuHandle() { $token = $this->getAppToken(session('ecid')); //如果接口信息不完整,直接返回 if ($token['weixin_AppId'] == '' || $token['weixin_AppSecret'] == '') { $this->ajaxReturn(Error::ERROR_MENU_TOKEN_EMPTY, Error::getErrMsg(Error::ERROR_MENU_TOKEN_EMPTY), 0); } $menu = $this->getMenuSet(session('ecid')); $menu_weixin = array('button' => ''); for ($i = 0; $i < count($menu); $i++) { $menu_weixin['button'][$i] = $this->changeWeixinArray($menu[$i], $token); if ($menu[$i]['hasSub'] == 1) { for ($j = 0; $j < count($menu[$i]['subitem']); $j++) { if (($menu[$i]['subitem'][$j]['responseType'] == null || $menu[$i]['subitem'][$j]['responseType'] == "text") && $menu[$i]['subitem'][$j]['responseText'] == "") { $data['data'] = ERROR::ERROR_MENU_REPLY_EMPTY; $data['info'] = $menu[$i]['subitem'][$j]['name'] . ":" . Error::getErrMsg(Error::ERROR_MENU_REPLY_EMPTY); $this->ajaxReturn($data, "JSON"); } } } else { if (($menu[$i]['responseType'] == "text" || $menu[$i]['responseType'] == null) && $menu[$i]['responseText'] == "") { $data['data'] = ERROR::ERROR_MENU_REPLY_EMPTY; $data['info'] = $menu[$i]['name'] . ":" . Error::getErrMsg(Error::ERROR_MENU_REPLY_EMPTY); $this->ajaxReturn($data, "JSON"); } } } $weObj = new \Org\Weixin\Wechat(); if ($weObj->checkAuth($token['weixin_AppId'], $token['weixin_AppSecret'])) { if ($tmp = $weObj->createMenu($menu_weixin)) { $data['data'] = Error::SUCCESS_OK; $data['info'] = Error::getErrMsg(Error::SUCCESS_OK); $this->ajaxReturn($data, 'JSON'); } } }