Ejemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $menu = Config::get('weixin.menu.buyer');
     $data_string = urldecode(json_encode($menu));
     $mq = new MQ();
     $access_token = $mq->getWeixinAccessTokenByName('buyer');
     $wxClient = new WeixinClient();
     $rt = $wxClient->setMenu($data_string, $access_token);
     if ($rt->errcode == 0) {
         $this->info('success');
     } else {
         $this->error(sprintf("failed, errcode: %d, errmsg: %s", $rt->errcode, $rt->errmsg));
     }
     return;
 }
Ejemplo n.º 2
0
 /**
  * @获取用户信息
  * @author zhengqian.zhu
  */
 public function saveUserInfo()
 {
     $mq = new MQ();
     $accessToken = $mq->getWeixinAccessTokenByName($this->type);
     if (!$accessToken) {
         throw new \Exception("get buyer access token error");
     }
     $userJson = WebAuth::getUserInfo($accessToken, $this->openid);
     $wxUserId = WxUser::saveWxUser($userJson);
     //保存卖家
     $buyer = new Buyer();
     $buyer->wx_user_id = $wxUserId;
     $buyer->save();
     Session::put('buyer_id', Buyer::where('wx_user_id', $wxUserId)->first()->id);
     \Log::info(sprintf("buyer_id : %s", $buyer));
     return $this->redirectRequestUrl();
 }
Ejemplo n.º 3
0
 /**
  * 获得微信jsapi的配置信息
  * @return stdClass
  */
 public function getJsapiConfig()
 {
     $mq = new MQ();
     $jsapiTicket = $mq->getWeixinJsapiTicketByName('buyer');
     $url = \Request::fullUrl();
     $noncestr = Tool::getRandChar(16);
     $timestamp = time();
     $weixinClient = new WeixinClient();
     $signature = $weixinClient->getSignature($jsapiTicket, $url, $noncestr, $timestamp);
     $config = new \stdClass();
     $config->jsapiTicket = $jsapiTicket;
     $config->url = $url;
     $config->noncestr = $noncestr;
     $config->timestamp = $timestamp;
     $config->signature = $signature;
     $config->appid = \Config::get('weixin.buyer.appid');
     return $config;
 }
Ejemplo n.º 4
0
 private function _sendTplMsg($data)
 {
     $mq = new MQ();
     $access_token = $mq->getWeixinAccessTokenByName('seller');
     $wxClient = new WeixinClient();
     $wxClient->sendTemplateMessage(json_encode($data), $access_token);
 }