xiaochenxu_script.py 3.07 KB
Newer Older
liuxiaoxing committed
1 2 3 4 5 6 7
import requests
import json
import time
import random

headers = {'Content-Type': 'application/json'}
#测试环境
liuxiaoxing committed
8 9 10
URL = 'http://10.2.20.42:8080/receive/tkio/event'
# URL = 'http://10.2.20.42:8080/receive/tkio/'

liuxiaoxing committed
11
#线上环境
liuxiaoxing committed
12
# URL = 'http://log.reyun.com/receive/tkio/event'
liuxiaoxing committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
# 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({
liuxiaoxing committed
37 38 39 40 41 42
                "what": "launch",
                 "appid": appid,
                 "context": {
                     "_cid": cid,
                     "_ip": IP,
                     "_deviceid": 'null',
liuxiaoxing committed
43
                     # "_openid":i,
liuxiaoxing committed
44 45 46
                     "_campaignid": surl,
                     "_sceneid": "unknown",
                     "_apptype": "wx"
liuxiaoxing committed
47
                 },
liuxiaoxing committed
48 49 50 51
                "where": "launch",
                "when": when,
                "ds": ds,
                "who": "lxx-test"
liuxiaoxing committed
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
            })
            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)