update
This commit is contained in:
parent
d607d55792
commit
bb11ed8c20
@ -10,19 +10,18 @@ import tornado.ioloop
|
||||
import tornado.web
|
||||
|
||||
def md5Sign(params, secret, timestamp, connstr = '&', secret_connstr = ':'):
|
||||
print('md5in')
|
||||
print(params)
|
||||
params_str = ''
|
||||
for key in sorted(params.keys()):
|
||||
params_str = params_str + key + '=' + str(params[key]) + connstr
|
||||
print(params_str)
|
||||
if params_str != '' and connstr != '':
|
||||
params_str = params_str[0:-1]
|
||||
m5 = hashlib.md5()
|
||||
|
||||
str1 = params_str + secret_connstr + str(timestamp) + secret
|
||||
m5.update(str1)
|
||||
try:
|
||||
m5 = hashlib.md5()
|
||||
m5.update(str1.encode('utf-8'))
|
||||
return m5.hexdigest()
|
||||
except Exception as e:
|
||||
print('md5Sign error: ' + str(e))
|
||||
|
||||
def getDaySeconds(time_val, incdays):
|
||||
time_zone = 8
|
||||
@ -35,13 +34,11 @@ def sendNotify(conf, sendtime):
|
||||
secret = 'fc38349c5d084e920925e614c420be9f'
|
||||
timestamp = time.time()
|
||||
md5signstr = md5Sign(params, secret, timestamp)
|
||||
print(md5signstr)
|
||||
url = conf['notify_url'] + '×tamp=' + timestamp + '&sign=' + md5signstr
|
||||
print(url)
|
||||
url = conf['notify_url'] + '×tamp=' + str(timestamp) + '&sign=' + md5signstr
|
||||
req = urllib.request.Request(url)
|
||||
data = urllib.request.urlopen(req).readall()
|
||||
except:
|
||||
pass
|
||||
data = urllib.request.urlopen(req).read()
|
||||
except Exception as e:
|
||||
print('sendNotifu error: ' + str(e))
|
||||
|
||||
#进入下一次循环
|
||||
tornado.ioloop.IOLoop.current().call_at(getDaySeconds(time.time(), 1) + sendtime,
|
||||
@ -63,14 +60,13 @@ def make_app():
|
||||
])
|
||||
|
||||
if __name__ == "__main__":
|
||||
print('start!')
|
||||
conf = json.loads(open('../config/kefu_robot.json', 'r').read())
|
||||
|
||||
app = make_app()
|
||||
app.listen(conf['listen_port'])
|
||||
|
||||
tornado.ioloop.IOLoop.current().call_at(getDaySeconds(time.time(), 1) + conf['sendtime1'],
|
||||
lambda : sendNotify(conf, conf['sendtime1']))
|
||||
tornado.ioloop.IOLoop.current().call_at(getDaySeconds(time.time(), 1) + conf['sendtime2'],
|
||||
lambda : sendNotify(conf, conf['sendtime2']))
|
||||
tornado.ioloop.IOLoop.current().call_at(time.time() + 3,
|
||||
lambda : sendNotify(conf, 30))
|
||||
tornado.ioloop.IOLoop.current().start()
|
||||
|
@ -28,6 +28,12 @@ class KefuController {
|
||||
return $conn;
|
||||
}
|
||||
|
||||
private function getDaySeconds($time_val, $incdays)
|
||||
{
|
||||
$time_zone = 8;
|
||||
return int(($time_val + $time_zone * 3600)/3600/24 + $incdays) * 3600 * 24 - 3600 * $time_zone;
|
||||
}
|
||||
|
||||
private function translateAttachments($config)
|
||||
{
|
||||
$attachments = '';
|
||||
@ -152,7 +158,7 @@ class KefuController {
|
||||
{
|
||||
if (phpcommon\md5Sign(array
|
||||
(
|
||||
'exclude_accountids' => $_REQUEST['key']
|
||||
'key' => 'kingsome'
|
||||
),
|
||||
'fc38349c5d084e920925e614c420be9f',
|
||||
$_REQUEST['timestamp']
|
||||
@ -241,8 +247,8 @@ class KefuController {
|
||||
}
|
||||
foreach ($rows as $row) {
|
||||
$shareInfo = require('../config/kefu.share.config.php');
|
||||
$gameid = phpcommon/extractGameId($row['accountid']);
|
||||
$this->sendKefuMsg($userInfo['accountid'],
|
||||
$gameid = phpcommon\extractGameId($row['accountid']);
|
||||
$this->sendKefuMsg($row['accountid'],
|
||||
array (
|
||||
"touser" => $row['openid'],
|
||||
"msgtype" => "miniprogrampage",
|
||||
@ -360,5 +366,4 @@ class KefuController {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ class WXBizMsgCrypt
|
||||
|
||||
//生成安全签名
|
||||
$sha1 = new SHA1;
|
||||
error_log('加密encrypt:' . $encrypt);
|
||||
#error_log('加密encrypt:' . $encrypt);
|
||||
$array = $sha1->getSHA1($this->token, $timeStamp, $nonce, $encrypt);
|
||||
$ret = $array[0];
|
||||
if ($ret != 0) {
|
||||
@ -217,8 +217,8 @@ class WXBizMsgCrypt
|
||||
}
|
||||
|
||||
$signature = $array[1];
|
||||
error_log($signature);
|
||||
error_log($msgSignature);
|
||||
#error_log($signature);
|
||||
#error_log($msgSignature);
|
||||
if ($signature != $msgSignature) {
|
||||
return ErrorCode::$ValidateSignatureError;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user