通过python 利用微信公众号,批量发送消息
但是,因为免费的,一天一个用户,只能发90条消息。。。
可以用于zabbix啊,。等监控
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
import sys
import simplejson as json
reload(sys)
sys.setdefaultencoding( "utf-8" )
class weChat:
def __init__(self, url, Corpid, Secret):
url = '%s/cgi-bin/gettoken?corpid=%s&corpsecret=%s' % (url, Corpid, Secret)
res = self.url_req(url)
self.token = res['access_token']
print self.token
def url_req(self, url, method='get', data={}):
if method == 'get':
req = urllib2.Request(url)
res = json.loads(urllib2.urlopen(req).read())
elif method == 'post':
req = urllib2.Request(url, data)
res =