import requests import json import time import random headers = {'Content-Type': 'application/json'} #测试环境 URL = 'http://10.2.20.42:8080/receive/tkio/event' # URL = 'http://10.2.20.42:8080/receive/tkio/' #线上环境 # URL = 'http://log.reyun.com/receive/tkio/event' # URL = 'http://tlog.trackingio.com/receive/tkio/event' #时间和日期 when = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) #日期 ds = time.strftime('%Y-%m-%d', time.localtime(time.time())) #访问时常,以s计时 duration = '5' #订单id transactionid = '34232323' # 支付类型 支付宝(alipay),银联(unionpay),微信支付(weixinpay),易宝支付(yeepay) paymenttype = 'alipay' #货币类型 currencytype = 'CNY' #支付金额 currencyamount = '45' #是否热云默认,标记为自定义事件 isreyundefaultevent = '' class allEvent: #打开小程序 def openxiaochengxu(self,i,IP,cid,surl,appid): s = json.dumps({ "what": "launch", "appid": appid, "context": { "_cid": cid, "_ip": IP, "_deviceid": 'null', # "_openid":i, "_campaignid": surl, "_sceneid": "unknown", "_apptype": "wx" }, "where": "launch", "when": when, "ds": ds, "who": "lxx-test" }) p = requests.post(url=URL, data=s, headers=headers, timeout=5) print(p.text) print(p.url) # pv def pviaochengxu(self, i, IP, cid, surl, appid): s = json.dumps({ "what": "pageview", "appid": appid, "context": { "_cid": cid, "_ip": IP, "_deviceid": i, "_openid": "xxxx", "_campaignid": surl, "_sceneid": "unknown", "_apptype": "wx" }, "where": "pageview", "when": when, "ds": ds, "who": "lxx-test" }) p = requests.post(url=URL, data=s, headers=headers, timeout=5) print(p.text) # hide def hidechengxu(self, i, IP, cid, surl, appid): s = json.dumps({ "what": "hide", "appid": appid, "context": { "_cid": cid, "_ip": IP, "_deviceid": i, "_openid": "xxxx", "_campaignid": surl, "_sceneid": "unknown", "_apptype": "wx", "_num_pages":"5", "_duration":"10" }, "where": "startup", "when": when, "ds": ds, "who": "lxx-test" }) p = requests.post(url=URL, data=s, headers=headers, timeout=5) print(p.text)