1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
import requests
import json
import time
import random
headers = {'Content-Type': 'application/json'}
URL = 'http://log.reyun.com/receive/tkio/event'
#时间戳
current_time_13 = int(round(time.time() * 1000))
#时间和日期
when = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
#日期
ds = time.strftime('%Y-%m-%d', time.localtime(time.time()))
#设备品牌
manufacturer = 'vivo'
#设备系统
ryos = 'android'
#设备类型
rydevicetype = 'vivox9'
#网络类型
network='wifi'
#分辨率
resolution='1344*750'
#运行商
op='中国移动'
# 支付类型 支付宝(alipay),银联(unionpay),微信支付(weixinpay),易宝支付(yeepay)
paymenttype = 'alipay'
#货币类型
currencytype = 'CNY'
#支付的货币金额
currencyamount = '45'
class allEvent:
# 激活
def installUpload(self,i,IP,appkey):
s = json.dumps({
"what":'install',
"appid":appkey,
"context":{
"_cmpaignid":'default',
"_deviceid":i,
"_idfa":i,
"_ip":IP,
'_manufacturer': manufacturer,
'_ryos': ryos,
'_rydevicetype': rydevicetype,
'_network': network,
'_resolution': resolution,
'_op':op,
#'_gaid': i,
'_timestamp':current_time_13
},
'when':time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
'ds':ds,
'who':'lxx_test'
})
p = requests.post(url=URL,data=s,headers=headers,timeout=5)
print(p.text)
#注册
def registerEvent(self,i,IP,appkey):
s = json.dumps({
'what':'register',
'appid':appkey,
'context':{
'_deviceid':i,
"_idfa":i,
'_ip':IP,
'_timestamp': current_time_13
},
'when':when,
'ds':ds,
'who':'lxx_test'
})
p = requests.post(url=URL,data=s,headers=headers,timeout=5)
print(p.text)
#登陆
def loginEvent(self,i,IP,appkey):
s = json.dumps({
'what': 'loggedin',
'appid': appkey,
'context': {
'_deviceid': i,
"_idfa":i,
'_ip': IP,
'_timestamp': current_time_13
},
'when': when,
'ds': ds,
'who': 'lxx_test'
})
p = requests.post(url=URL, data=s, headers=headers, timeout=5)
print(p.text)
#付费
def payEvent(self,i,IP,appkey):
#订单号
transactionid = ''.join(str(random.choice(range(10))) for _ in range(19))
s = json.dumps({
'what': 'payment',
'appid': appkey,
'context': {
'_deviceid': i,
"_idfa":i,
'_ip': IP,
'_timestamp': current_time_13,
'_transactionid':transactionid,
'_paymenttype': paymenttype,
'_currencytype': currencytype,
'_currencyamount': currencyamount,
},
'when': when,
'ds': ds,
'who': 'lxx_test'
})
p = requests.post(url=URL, data=s, headers=headers, timeout=5)
print(p.text)
# 订单
def orderEvent(self, i, IP, appkey):
# 订单号
transactionid = ''.join(str(random.choice(range(10))) for _ in range(19))
s = json.dumps({
'what': 'order',
'appid': appkey,
'context': {
'_deviceid': i,
"_idfa":i,
'_ip': IP,
'_timestamp': current_time_13,
'_transactionid': transactionid,
'_paymenttype': paymenttype,
'_currencytype': currencytype,
'_currencyamount': currencyamount,
},
'when': when,
'ds': ds,
'who': 'lxx_test'
})
p = requests.post(url=URL, data=s, headers=headers, timeout=5)
print(p.text)
#自定义事件
def ziding_event(self,i,IP,appkey,event):
s = json.dumps({
'what': event,
'appid': appkey,
'context': {
'_deviceid': i,
"_idfa":i,
'_ip': IP,
#识别是否为自定义事件,默认传1
'_isreyundefaultevent':'1'
},
'when': when,
'ds': ds,
'who': 'lxx_test'
})
p = requests.post(url=URL, data=s, headers=headers, timeout=5)
print(p.text)
# 启动
def startupEvent(self, i, IP, appkey):
s = json.dumps({
'what': 'startup',
'appid': appkey,
'context': {
'_deviceid': i,
'_idfa': i,
'_ip': IP,
'_timestamp': current_time_13
},
'when': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
'ds': ds,
'who': 'lxx_test'
})
p = requests.post(url=URL, data=s, headers=headers, timeout=10)
print(p.text)