public function invitationGet()
 {
     $openid = I('get.u');
     $companyInfo = $this->getCompanyInfo();
     $options = array('token' => 'tokenaccesskey', 'appid' => $companyInfo['weixin_AppId'], 'appsecret' => $companyInfo['weixin_AppSecret']);
     $weixin = new TPWechat($options);
     if (!$openid) {
         $oauthToken = $weixin->getOauthAccessToken();
         if (!$oauthToken) {
             $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];
             //$url = urlencode($url);
             $redirctUrl = $weixin->getOauthRedirect($url, '', 'snsapi_base');
             header("Location: {$redirctUrl}");
         }
         $openid = $oauthToken['openid'];
     }
     $this->assign('openid', $openid);
     $auth = $weixin->checkAuth();
     $api_ticket = $weixin->getJsTicket();
     $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $js_sign = $weixin->getJsSign($url);
     $time = time();
     $card_id = 'pk0Ius992-phYJGSJLG2dJfBuFvw';
     $this->assign('card_id', $card_id);
     $signature = new Signature();
     $signature->add_data($api_ticket);
     $signature->add_data($card_id);
     $signature->add_data(strval($time));
     $this->assign('card_signature', $signature->get_signature());
     $this->assign('js_sign', $js_sign);
     $this->assign('tm', $time);
     $this->assign('api_ticket', $api_ticket);
     $this->display();
 }
示例#2
0
 public static function getJsSdkSign()
 {
     $appid = C('WECHAT_APPID');
     $appsecret = C('WECHAT_SECRET');
     $options = array('appid' => $appid, 'appsecret' => $appsecret);
     $weObj = new TPWechat($options);
     $auth = $weObj->checkAuth();
     $api_ticket = $weObj->getJsTicket();
     $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     return $weObj->getJsSign($url);
 }
示例#3
0
 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\TPWechat();
     if ($weObj->checkAuth($token['weixin_AppId'], $token['weixin_AppSecret'])) {
         $qrCode = $weObj->getQRCode($sceneId, 0);
         if ($qrCode) {
             return $weObj->getQRUrl($qrCode['ticket']);
         }
     }
 }
示例#4
0
 public function news()
 {
     $userInfo = \Mobile\Gereral\User::getUserInfo();
     $data = M("Company_news")->where("id = " . $_GET["id"])->find();
     $data['content'] = htmlspecialchars_decode($data['content']);
     $params = I('get.');
     $this->saveRead($params);
     $this->assign('userInfo', $userInfo);
     $this->assign('newsArr', $data);
     //$this->assign( 'params', $session);
     //
     $weObj = new TPWechat(array('appid' => 'wx043fe26d7171dc76', 'appsecret' => '9075a78a413ea5f12999e0fddcc2a60c'));
     $auth = $weObj->checkAuth();
     $api_ticket = $weObj->getJsTicket();
     $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $js_sign = $weObj->getJsSign($url);
     $time = time();
     $this->assign('js_sign', $js_sign);
     $this->display();
     // if(S('news_view_'.$params['r'])){
     //   $this->assign( 'newsArr' , $data );
     //   $this->assign( 'params', $session);
     //   $this->display();
     // }else{
     //   $url = \Weixin\Response\WechatConst::REDIRECT_DOMAIN . "ecid={$params['ecid']}&type=news&fromOpenId={$params['openid']}&from_type=1&newsId={$params['id']}";
     //   $base_url = $this->getOauthUrl($url, $params['ecid']);
     //   header("Location: {$base_url}");
     // }
 }
示例#5
0
 private function getJsSdkPrams()
 {
     $weObj = new TPWechat(array('appid' => 'wx043fe26d7171dc76', 'appsecret' => '9075a78a413ea5f12999e0fddcc2a60c'));
     $auth = $weObj->checkAuth();
     $api_ticket = $weObj->getJsTicket();
     $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $js_sign = $weObj->getJsSign($url);
     return $js_sign;
 }