Ejemplo n.º 1
0
 public function send($xml = false)
 {
     $biz = new \handler\mp\WXBizMsgCrypt($this->account->token, $this->account->encoding_aes_key, $this->account->app_id);
     if (!$xml) {
         $xml = "<xml><ToUserName><![CDATA[oia2Tj我是中文jewbmiOUlr6X-1crbLOvLw]]></ToUserName><FromUserName><![CDATA[gh_7f083739789a]]></FromUserName><CreateTime>1407743423</CreateTime><MsgType><![CDATA[video]]></MsgType><Video><MediaId><![CDATA[eYJ1MbwPRJtOvIEabaxHs7TX2D-HV71s79GUxqdUkjm6Gs2Ed1KF3ulAOA9H1xG0]]></MediaId><Title><![CDATA[testCallBackReplyVideo]]></Title><Description><![CDATA[testCallBackReplyVideo]]></Description></Video></xml>";
     }
     $result = '';
     $code = $biz->encryptMsg($xml, time(), \Str::random('alnum', 16), $result);
     if ($code) {
         die('加密失败:' . $code);
     }
     die($result);
 }
Ejemplo n.º 2
0
Archivo: wxapi.php Proyecto: wxl2012/wx
 /**
  * 处理微信推送的请求
  *
  * @access  private
  * @return  void
  */
 private function handler()
 {
     $post = $GLOBALS['HTTP_RAW_POST_DATA'];
     if (!$post) {
         \Log::error("未能识别请求数据(未获取到HTTP_RAW_POST_DATA)");
         die;
     }
     $data = [];
     try {
         $data = simplexml_load_string($post, 'SimpleXMLElement', LIBXML_NOCDATA);
     } catch (Exception $e) {
         \Log::error('解析HTTP_RAW_POST_DATA数据时,发生异常:' . $e->getMessage());
         die('系统繁忙,请重试!');
     }
     if (isset($this->account->encoding_aes_key) && $this->account->encoding_aes_key) {
         $biz = new \handler\mp\WXBizMsgCrypt($this->account->token, $this->account->encoding_aes_key, $this->account->app_id);
         $code = $biz->decryptMsg(\Input::get('msg_signature', false), \Input::get('timestamp', false), \Input::get('nonce', false), $post, $data);
         if (\handler\mp\ErrorCode::$OK != $code) {
             \Log::error('解密消息时失败:' . $code);
             die;
         }
         $data = simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA);
     }
     $request = new \handler\mp\Request($data);
     $request->handle();
 }