In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Python2.x Note: in the data variable, agent_id is the target department for the newly created application id (which can be seen on the web page), or you can use touser,totag to specify a relatively simple call to the target account, which has been tested and can be used. # coding:utf-8import sysimport requestsimport jsonfrom pymongo import MongoClientreload (sys) sys.setdefaultencoding ('utf-8') class Weixin (object): def _ _ init__ (self, corp_id, corp_secret): self.token_url =' https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=%s&corpsecret=%s'% (corp_id) Corp_secret) self.send_url = 'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=' def get_token (self): try: r = requests.get (self.token_url) Timeout=10) except Exception as e: print e sys.exit (1) if r.status_code = = requests.codes.ok: data = r.json () if data.get ('errcode'): print data [' errmsg'] sys.exit (1) return data ['access_token'] Else: print r.status_code sys.exit (1) def send (self Message): url = self.send_url + self.get_token () data = {"touser": "hequan2011", "msgtype": "text", "agentid": "0", "text": {"content": message} "safe": "0"} send_data = json.dumps (data,ensure_ascii=False) try: r = requests.post (url, send_data) except Exception E: print e sys.exit (1) if r.status_code = = requests.codes.ok: print r.json () else: print r.code sys.exit (1) corpid = 'xxxxxxxxxxx'corpsecret =' xxxxxxxxxxxxxxxxx'client = MongoClient ('mongodb://user:password@127.0.0.1: 27017 data') db = client.kucollection = db.biaoa = [] for data in collection.find (): a.append (data) l = a [0] g = lz = str (g ["name"]) Z1 = int (g ["jg"]) print zmsg = "1: {0}\ n 2: {1}\ n" .format (z Z1) w = Weixin (corpid,corpsecret) w.send (msg)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
1.Flashback queryDepend on:content in undo tablespace1.1Base syntax: 1: SELECT... FROM... AS OF
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.