Class WeChatOpenRestNotification

java.lang.Object
com.bytedesk.wechat.open.WeChatOpenRestNotification

@RestController @RequestMapping("/wechat/open") public class WeChatOpenRestNotification extends Object
对接微信开放平台,授权方式对接, https://open.weixin.qq.com/, 第三方平台
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    fullNetPublish(me.chanjar.weixin.mp.bean.message.WxMpXmlMessage inMessage, String requestBody, String appId, String signature, String timestamp, String nonce, String openid, String encType, String msgSignature)
     
    void
    gotoPreAuthUrl(jakarta.servlet.http.HttpServletResponse response)
    跳转到微信授权页面 扫码授权 wechat.bytedesk.com/wechat/mp/oauth/redirect/{uid} 说明 https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/Authorization_Process_Technical_Description.html 预授权链接格式: https://mp.weixin.qq.com/cgi-bin/componentloginpage?
    msgEventCallback(String requestBody, String appId, String signature, String timestamp, String nonce, String openid, String encType, String msgSignature)
    接收消息推送
    void
    oauthCallback(String authorizationCode, jakarta.servlet.http.HttpServletResponse response)
    使用授权码获取授权信息 https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/api/authorization_info.html 处理授权事件Get 授权成功之后回调地址 因为post过来的信息,服务端拿不到user_id, 而且消息一般都是post先到,然后浏览器回调,执行get, 才能够从session中拿到user_id,故基于以上原因(假设),在此处更新user_id 绑定公众号到管理员所属的默认工作组
    oauthCallback(String requestBody, String timestamp, String nonce, String signature, String encType, String msgSignature, jakarta.servlet.http.HttpSession session)
    处理授权事件POST 授权事件接收URL wechat.bytedesk.com/wechat/mp/oauth/callback 授权过程中: 1.
    org.springframework.http.ResponseEntity<?>
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • WeChatOpenRestNotification

      public WeChatOpenRestNotification()
  • Method Details

    • prepare

      @GetMapping("/prepare") public org.springframework.http.ResponseEntity<?> prepare(@RequestParam("url") String url)
    • gotoPreAuthUrl

      @GetMapping("/oauth/redirect") public void gotoPreAuthUrl(jakarta.servlet.http.HttpServletResponse response)
      跳转到微信授权页面 扫码授权 wechat.bytedesk.com/wechat/mp/oauth/redirect/{uid} 说明 https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/Authorization_Process_Technical_Description.html 预授权链接格式: https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=xxxx&pre_auth_code=xxxxx&redirect_uri=xxxx&auth_type=1
      Parameters:
      response - response
    • oauthCallback

      @PostMapping("/oauth/callback") public Object oauthCallback(@RequestBody(required=false) String requestBody, @RequestParam("timestamp") String timestamp, @RequestParam("nonce") String nonce, @RequestParam("signature") String signature, @RequestParam(name="encrypt_type",required=false) String encType, @RequestParam(name="msg_signature",required=false) String msgSignature, jakarta.servlet.http.HttpSession session)
      处理授权事件POST 授权事件接收URL wechat.bytedesk.com/wechat/mp/oauth/callback 授权过程中: 1. 首先接收到POST请求结果, 2. 最后是GET请求,在GET函数里面执行页面跳转
      Parameters:
      requestBody - body
      timestamp - time
      nonce - nonce
      signature - sign
      encType - enc
      msgSignature - sign
      session - session
      Returns:
      object
    • oauthCallback

      @GetMapping("/oauth/callback") @ResponseBody public void oauthCallback(@RequestParam("auth_code") String authorizationCode, jakarta.servlet.http.HttpServletResponse response)
      使用授权码获取授权信息 https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/api/authorization_info.html 处理授权事件Get 授权成功之后回调地址 因为post过来的信息,服务端拿不到user_id, 而且消息一般都是post先到,然后浏览器回调,执行get, 才能够从session中拿到user_id,故基于以上原因(假设),在此处更新user_id 绑定公众号到管理员所属的默认工作组
      Parameters:
      authorizationCode - code
      response - response
    • msgEventCallback

      @RequestMapping("/msgevent/{appId}/callback") public Object msgEventCallback(@RequestBody(required=false) String requestBody, @PathVariable("appId") String appId, @RequestParam("signature") String signature, @RequestParam("timestamp") String timestamp, @RequestParam("nonce") String nonce, @RequestParam("openid") String openid, @RequestParam("encrypt_type") String encType, @RequestParam("msg_signature") String msgSignature)
      接收消息推送
      Parameters:
      requestBody - body
      appId - app
      signature - sign
      timestamp - time
      nonce - nonce
      openid - id
      encType - enc
      msgSignature - sign
      Returns:
      object
      See Also:
    • fullNetPublish

      public Object fullNetPublish(me.chanjar.weixin.mp.bean.message.WxMpXmlMessage inMessage, String requestBody, String appId, String signature, String timestamp, String nonce, String openid, String encType, String msgSignature)
      Parameters:
      inMessage - in
      requestBody - body
      appId - appid
      signature - sig
      timestamp - timestamp
      nonce - nonce
      openid - openid
      encType - enctype
      msgSignature - msg
      Returns:
      json
      See Also:
      • 全网发布接入检测说明 使用: return fullNetPublish(inMessage, requestBody, appId, signature, timestamp, nonce, openid, encType, msgSignature); 自动化测试的专用测试公众号的信息如下: (1)appid: wx570bc396a51b8ff8 (2)Username: gh_3c884a361561 自动化测试的专用测试小程序的信息如下: (1)appid:wxd101a85aa106f53e (2)Username: gh_8dad206e9538