Package com.bytedesk.wechat.open
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfullNetPublish
(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<?>
-
Field Details
-
weChatOpenConfig
-
-
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
- bodytimestamp
- timenonce
- noncesignature
- signencType
- encmsgSignature
- signsession
- 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
- coderesponse
- 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
- bodyappId
- appsignature
- signtimestamp
- timenonce
- nonceopenid
- idencType
- encmsgSignature
- 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
- inrequestBody
- bodyappId
- appidsignature
- sigtimestamp
- timestampnonce
- nonceopenid
- openidencType
- enctypemsgSignature
- 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
-