求示例代码,python 或者C#
智能对话-发送客服消息?https://openai.weixin.qq.com/openapi/sendmsg/{TOKEN} 能给一个完整的示例吗? 接口一直报 {"errcode":1019,"errmsg":"data encrypt is incorrect, please check the doc.","rid":"1c0daf82"}
2021-04-08错误1013的谁解决了有偿求教啊
智能对话文档中设置批量导入(普通)技能接口404?调用的接口地址https://openai.weixin.qq.com/openapi/batchimportskill/bZckp5aTH2HydICjBAdpmBBdT47brr xml加密完成,按文档要求将加密后的数据,以字段 encrypt 放入body中,接口返回404, 其中headers的设置是{'Content-Type', 'application/json'} 如果不设置headers接口返回 {'errcode': 1013, 'errmsg': 'decrypt error, please use the correct way to encrypt the params.'} 貌似这种需要在body中添加加密xml字段的接口都是如此,前面使用发送客服消息接口也是报一样的错误 开发语言python代码片段 def batchimportskill(self): urls = [ "https://openai.weixin.qq.com/openapi/batchimportskill/bZckp5aTH2HydICjBAdpmBBdT47brr" ] headers = { "Content-Type": "application/json;charset=UTF-8" } param = {'managerid': "mzZqGup3tUs"} skill_xml_list = [] for i in range(0, 2): skill_xml_list.append( f"""<skill><skillname><![CDATA[技能名称1]]></skillname><title><![CDATA[标准问题3]]></title><question><![CDATA[相似问题1]]></question><answer><![CDATA[1]]></answer></skill>""") s_nonce = ''.join(random.sample('zyxwvutsrqponmlkjihgfedcba', 10)) xml = f"""<xml><managerid><![CDATA[{param['managerid']}]]></managerid>{''.join(skill_xml_list)}</xml>""" cryptor = WXBizMsgCrypt(self.TOKEN, self.EncodingAESKey, self.APPID) code, encrypt_xml = cryptor.EncryptMsg(xml, s_nonce) print(encrypt_xml) if code == 0: skill_xml_encrypt = { 'encrypt': encrypt_xml } data = json.dumps(skill_xml_encrypt, ensure_ascii=False).encode('utf-8') tasks = [grequests.post(u, data=data, headers=headers) for u in urls] resp = grequests.map(tasks, size=3) print(resp) if resp is None: return False if resp[0].status_code == 200: resp_dict = json.loads(resp[0].content.decode(encoding='utf-8')) print(resp_dict) else: return False
2021-04-06