Skip to content

WeChat Integration

  • WeChat-related integrations cover many scenarios
  • WeChat Pay
  • WeChat Official Account Login
  • WeChat Official Account QR Code Follow & Login

QR Code Follow & Login (Official Account)

json
{
  "ticket": "gQH88DwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyaGtSNnNQdTVkMEMxYUlIYmhDYzMAAgScnQtmAwQQDgAA",
  "expire_seconds": 3600,
  "url": "http://weixin.qq.com/q/02hkR6sPu5d0C1aIHbhCc3",
  "checkUrl": "/oauth/weixin/token/chat:Dnqffxgt"
}
{
  "ticket": "gQH88DwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyaGtSNnNQdTVkMEMxYUlIYmhDYzMAAgScnQtmAwQQDgAA",
  "expire_seconds": 3600,
  "url": "http://weixin.qq.com/q/02hkR6sPu5d0C1aIHbhCc3",
  "checkUrl": "/oauth/weixin/token/chat:Dnqffxgt"
}
  • After the user follows, write the wxid to the backend and store it in Redis
  • Poll checkUrl to check if the user has scanned (checks Redis for wxid); if found, set cookies accordingly

WeChat Official Account Login (In-App)

  • Use case: inside WeChat on mobile
  • Reference: visit https://ai.minihuo.com inside WeChat
  • Redirect to https://www.lingduquan.com/oauth/weixin?f=chat — this sets a cookie based on the source
  • Step 2: determine which wxapp based on source, then get the required key and URL
  • Step 3: get code and complete login