收藏
回答

调用小程序订阅消息服务器API subscribeMessage.send的疑问?

微信公众平台接口调试工具调试时的获得回调是:

后端代码:

import requests

def get_access_token():

    appid = 'wx6ac3ca8cc6189b5b'

    app_secret = APP_SECRET

    url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' + appid + '&secret=' + app_secret
    r = requests.get(url)

    access_token = r.json()['access_token']

   return access_token


def postToUrlOfAllParticipate1(activity, participate, access_token):
    url = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=' + access_token
    paramsOfParticpate = {
      "touser": "okSsB5eqW2X33tkbiEfh7QRetP9g",
      "template_id": "3HNEeIjVsSDRLXjIkMAmEJmyLc9SOq8aalnB9hkZT9s",
      "page": "pages/activityInfo/activityInfo/?activity_id=8",
      "data": {
          "thing8": {
              "value": "最终开奖结果请已彩票官网为准"
          },
          "thing10": {
              "value": "电动牙刷"
          }
      }
    }

    paramsJson = json.dumps(paramsOfParticpate)

   # messageSendToParticpate = requests.post(url=url, data=paramsOfParticpate)

    messageSendToParticpate = requests.post(url=url, data=paramsJson, headers={'Content-Type': 'application/json'})
    print(messageSendToParticpate)
    print(messageSendToParticpate.text)

但实际上,当我将paramsOfParticpate变量转成JSON后再传递给服务器上的回调却是:
{"errcode":47001,"errmsg":"data format error hint: [BlRlUa08685508]"}

如果我直接将paramsOfParticpate作为参数传递给API则得到:

"errcode":40003,"errmsg":"invalid


既然能在微信公众平台接口调试工具中能够获得别的回调,那为何在服务器上获得的回调却是别的?我确定自己的appid、app_secret是当前小程序的。那么问题到底出在哪?

最后一次编辑于  11-21
回答关注问题邀请回答
收藏

1 个回答

问题标签