1.一、
2.由于微信个人订阅号目前很多功能还没开通,所以采用微信公众平台测试帐号,
3.用微信扫码登录就可以获得一个自己的微信测试号:
4.扫码关注测试账号:
5.各种功能接口文档都有提供,可根据需求自行查看。
6.如果要在线调试接口,需要自己申请一个订阅号,登陆之后,点击开发者工具-在线调试工具
7.二、
8.上面的准备工作做完了,就可以开始调用接口实现功能了。
#coding:utf-8importtimeimportdatetimeimportosimportConfigParserimportrequestsimportjsonclassMsgToWeiXin(object):def__init__(self):self._configConfigParser.SafeConfigParser()#self._config.read('config.ini')batRunningPathos.path.dirname(os.sys.executable)batPathos.path.dirname(os.sys.path[0])ifos.path.exists(batPath+"MsgToWeiXinconfig.ini"):self._config.read(batPath+"MsgToWeiXinconfig.ini")else:self._config.read(batRunningPath+"config.ini")self._access_token""self._expires_in7200self._token_getTime0self._appidself._config.get("weixin","appid")self._secretself._config.get("weixin","secret")self._touserself._config.get("weixin","touser")self._togroupself._config.get("weixin","groupid")datenowdatetime.datetime.now()datenowdatenow.strftime("%Y%m%d")self._nToDaydatenowself._msg""defgetMsgFromTxt(self):datenowdatetime.datetime.now()datenowdatenow.strftime("%Y%m%d")strFileNamestr(datenow)+"_IndexServerInterface.txt"printstrFileNametry:forlineinopen(strFileName):ifline!"":self._msg+linereturnTrueexceptException,e:printstr(e)returnFalsedefget_token(self):url'https://api.weixin.qq.com/cgi-bin/token'values{'grant_type':'client_credential','appid':self._appid,'secret':self._secret,}reqrequests.get(url,paramsvalues)datareq.json()self._token_getTimetime.time()self._access_tokendata["access_token"]self._expires_indata["expires_in"]defsend_msg(self):url"https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token"+self._access_tokencontent"Date:{0},r{1}r".format(self._nToDay,self._msg)values{"touser":self._touser,"msgtype":"text","text":{"content":content}}#header{"content-Type":"application/json"}#reqrequests.post(url,datajson.dumps(values),headersheader)reqrequests.post(url,datajson.dumps(values,ensure_asciiFalse))resultreq.json()returnresult['errcode']defsend_msg_group(self):url"https://api.weixin.qq.com/cgi-bin/message/mass/sendall?access_token"+self._access_tokencontent"Date:{0},r{1}r".format(self._nToDay,self._msg)values{"filter":{"is_to_all":False,"group_id":self._togroup,},"msgtype":"text","text":{"content":content}}#header{"content-Type":"application/json"}#reqrequests.post(url,datajson.dumps(values),headersheader)reqrequests.post(url,datajson.dumps(values,ensure_asciiFalse))resultreq.json()returnresult['errcode']if__name__'__main__':msgToWXMsgToWeiXin()ifTruemsgToWX.getMsgFromTxt():ifmsgToWX._msg!"":printmsgToWX._msgelse:msgToWX._msg+"指标数据正常"msgToWX.get_token()if0msgToWX.send_msg():print"sendsuccess"else:print"sendfailed"else:print"getMsgFromTxterror"9.10.
Linux下报错:ImportError:Nomodulenamed'requests.packages.urllib3'
11.解决方法:https://www.cnblogs.com/SZxiaochun/p/9831389.html
使用微信公众号实现监控告警-微信公众号接入监控视频-微信小程序可以直播吗
浏览量:3516
时间:
来源:weixin_33894992
版权声明
即速应用倡导尊重与保护知识产权。如发现本站文章存在版权问题,烦请提供版权疑问、身份证明、版权证明、联系方式等发邮件至197452366@qq.com ,我们将及时处理。本站文章仅作分享交流用途,作者观点不等同于即速应用观点。用户与作者的任何交易与本站无关,请知悉。
最新资讯
-

即速应用,赋能企业玩转微信小程序智慧经营
作为国内领军的智慧商业经营服务商,即速应用始终秉承“让每个企业都拥有自己的智慧店铺”的愿景,持续赋能更多企业玩转智慧经营。即速应用旗下拥有“小程序搭建工具-即速应用”、“私域流量专家-即客云”等产品,帮助商家打通互联网全生态营销闭环。 -

即客云2.0重磅更新,让微信小程序运营更简单!
即客云作为一款基于企业微信的第三方工具,现从多维度提供超过30种功能,自上线以来,已服务多家企业,受到一致好评。近期,我们根据客户反馈和市场调研正式推出升级版 即客云2.0!更新了私域运营SOP,群日历功能,批量拓客,客户雷达,消息推送,个人欢迎语,帮助企业更好运用企业微信;同时提升了社群运营工作标准化,提升运营效率,帮助企业实现客户增长,玩转私域流量。 -

零代码 + AI 双轮驱动|即速应用解锁人工智能小程序开发新范式
无需代码、无需 AI 算法功底,普通人也能快速搭建智能小程序。即速应用将人工智能与零代码开发深度融合,推出 AI 智能生成能力,用户通过自然语言描述需求,AI 自动生成小程序页面、功能模块与后台配置,覆盖商城、预约、同城、社区团购等全场景。平台内置 AI 智能推荐、智能客服、用户画像分析等能力,一键对接微信生态,打通视频号、企业微信、短信跳转,帮企业快速落地 AI 应用,抢占智慧经营先机,让每家企业都拥有 AI 驱动的智慧店铺。










