android_script.py 32.8 KB
Newer Older
liuxiaoxing committed
1 2 3 4 5
import requests
import json
import time
import random

liuxiaoxing committed
6
headers = {'Content-Type': 'application/json', 'X-RY-Access-Token': 'test_access_token'}
liuxiaoxing committed
7

liuxiaoxing committed
8 9
# 测试环境
URL_batch = 'http://10.3.20.42:8080/receive/batch'
liuxiaoxing committed
10 11
URL = 'http://10.2.20.42:8080/receive/tkio/'
# URL = 'http://log.trackingio.com/receive/tkio/'
liuxiaoxing committed
12
# URL = 'http://jisulog.sortda.com/receive/tkio/'
liuxiaoxing committed
13 14 15 16 17
# URL = 'http://172.31.21.207:8080/receive/tkio/'
# URL = 'http://120.53.212.71/receive/tkio/'
# 腾迅云tkio http协议的生产地址:
# URL = 'http://tlog.trackingio.com/receive/tkio/'

liuxiaoxing committed
18
# 时间戳
liuxiaoxing committed
19
current_time_13 = int(round(time.time() * 1000))
liuxiaoxing committed
20
# 时间和日期
liuxiaoxing committed
21
when = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
liuxiaoxing committed
22
# 日期
liuxiaoxing committed
23
ds = time.strftime('%Y-%m-%d', time.localtime(time.time()))
liuxiaoxing committed
24
# 设备品牌
liuxiaoxing committed
25
manufacturer = 'vivo'
liuxiaoxing committed
26 27 28
# 设备系统
ryos = 'android'
# 设备类型
liuxiaoxing committed
29
rydevicetype = 'vivox9'
liuxiaoxing committed
30 31 32 33 34 35
# 网络类型
network = 'wifi'
# 分辨率
resolution = '1344*750'
# 运行商
op = '中国移动'
liuxiaoxing committed
36 37
# 支付类型   支付宝(alipay),银联(unionpay),微信支付(weixinpay),易宝支付(yeepay)
paymenttype = 'alipay'
liuxiaoxing committed
38
# 货币类型
liuxiaoxing committed
39
currencytype = 'CNY'
liuxiaoxing committed
40
# 支付的货币金额
liuxiaoxing committed
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
currencyamount = '90'
# # 填充广告在变现平台的广告位ID
# adid = '839296815'
# 填充广告的变现平台,例如穿山甲(csj)、优量汇(ylh)、百青藤(bqt)、Sigmob(sigmob)、快手(ks)、Mintegral(mintegral)、OneWay(oneway)、Vungle(vungle)等
adPlatform = 'ylh'
# 页面展示时调用 pageID代表页面唯一标识
# 会话时长,单位秒
appduration = '600'
# 时长,单位:秒
pageduration = '200'
istablet = 'phone'
lib = 'ios'
when1 = '2020-06-06 16:44:31'
# 设备型号
model = '测试1'
# 操作系统版本
ryosversion = '13.6.1'
# 网络环境
network_type = '5g'
# 运营商
carrier = '中国联通'
lv = '1.8.5'


class allEvent:
    # 激活
    def installUpload(self, i, IP, appkey):
        s = json.dumps({
            # "what":'install',
            "appid": appkey,
            "context": {
                "_carrier": carrier,
                "_networkwhat_type": network_type,
                "_ryosversion": ryosversion,
                "_model": model,
                "_pkgname": "com.yanjing.yami",
liuxiaoxing committed
77
                # "_campaignid": 'default',
liuxiaoxing committed
78
                "_deviceid": i,
liuxiaoxing committed
79 80 81
                "_imei": 'E83DC0B76BC1691CB9C45E5A63468660',
                # '_oaid': '697134960e9ff8df46f21b4f97db595a1',
                # "_rdid": '09DA91D0664C33DA7BEE7294CCCCCA07',
liuxiaoxing committed
82
                # 'ua': 'Mozilla/5.0 (Linux; U; Android 7.0; zh-CN; Nexus 5X Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/40.0.2214.89 UCBrowser/11.4.5.937 Mobile Safari/537.36',
liuxiaoxing committed
83
                # "idfa": i,
liuxiaoxing committed
84 85 86
                # "_current_caid": "00_A0FF634AEDF1403205A4A6A1118CDA61_A66338F33BEBB40F5CD65F198AF2F40C",
                # "gxid": "876543567543565",
                # "_idfv": i,
liuxiaoxing committed
87
                # "_androidid": '86ab7f6642bdde717709216e68d0b',
liuxiaoxing committed
88 89 90 91 92 93 94 95 96 97 98 99 100
                # "_imei2":"324323AAAA",
                # "_meid": "CCC324323",
                "_ip": IP,
                # "_ipv6": i,
                '_manufacturer': manufacturer,
                '_ryos': ryos,
                '_rydevicetype': rydevicetype,
                '_network': network,
                '_resolution': resolution,
                '_op': op,
                '_timestamp': current_time_13,
                '_mac': "5432453241421",
                "_istablet": istablet,
liuxiaoxing committed
101 102 103 104
                "_lib": lib,
                "_lib_version": lv
                # "verify": "{\"result\":\"{\"errorMsg\":\"实名认证失败\"}\"}"
,
liuxiaoxing committed
105 106 107 108 109 110 111 112 113 114 115 116 117

                # 'sysfsize': '111',
                # '_model': '1',
                # 'sysram': '1',
                # '_ryosversion': '1',
                # 'sysutime': '1',
                # 'sysuname': '1',
                # '_carrier': '1',
                # 'syscountryc': '1',
                # 'sysrtime': '1',



liuxiaoxing committed
118
                # "asatoken": "PLEU97c4CmufaE1LSl1WtLiJYp/uAzaw2/u1ClT+/3oOXTZioJj7HQIYfPwXFWajiQSKEQKrVPsMnWQehYxKvM738taR5TvFewAAAVADAAAAywAAAIB8/odC2bsr2fCP0zyFh2a48uyqcqFV3Wn0H+OnHN503dkHiCpsUaiHAptHQ/rAZgwXbtOXr4614Qabc0C6/55eP4mcFycPe24Q6rnkFl5ShwZmeEvu7I/oDWoDFkVKu0zD1g5dI6+yBI6Eb/Jj64OUAv6vpadD2SjJmqyBKHzhoAAAAB+I7jKYVGw7cbkI3+pjVhmfRPcq/WqGUP/FQhenKvuzAAAAnwGApEjvnfSmSwNz08eBOarI6h0R/AAAAIYEBDPzgQTIVpZBqceNqDtPiNNg0gYO9zXPdYKgB+aWtBsu5f6dUTZ/cA0Q2igUO7WpNTVOLT8HiA9GwulZtKM87LwOoD/p4Km9wFfsbZgxSnt6sgYGCfFY4GehIKqsNeuCUS+9M4/Z2LRIcWEXkbhm/AE1XsmemM5JjB8P8+wGe0Mb5Xb1XQABBEUNAAA=",
liuxiaoxing committed
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

                # "_oaid_limited": "false",
                # "_app_version": "1.2.0_1565149_1627898",
                # "_timestamp": "1611131462864",
                # "_province": "湖北",
                # "_city": "武汉",
                # "_carrier": "unknown",
                # "_ryos": "Android",
                # "_ry_ts": "1611131463068",
                # "_oaid": "5c70287b-27f5-4ac3-9e9c-2d67b8cf1065",
                # "_pkgname": "com.miHoYo.Yuanshen",
                # "_lib_version": "1.6.2",
                # "_ucid": "unknown",
                # "_ryandroid8version": "29",
                # "_model": "ASK-AL20",
                # "_istablet": "phone",
                # "_mac": "DE:12:94:7D:78:E4",
                # "_ryosversion": "10",
                # "_rydevicetype": "ASK-AL20",
                # "_ry_origin_when": "2021-01-20 16:31:03",
                # "_imei": "5c70287b-27f5-4ac3-9e9c-2d67b8cf1065",
                # "_meid": "unknown",
                # "_lib": "Android",
                # "_tz": "+8",
                # "_audio_volume": "0",
                # "_manufacturer": "HUAWEI",
                # "_create_timestamp": "1611131463351",
                # "_ip": IP,
                # "_imei2": "unknown",
                # "_resolution": "1412*720",
                # "_campaignid": "1",
                # "_bd_vid": "unknown",
                # "_ipv6": "240e:45f:7200:21fb:a81c:2870:e657:4ab6",
                # "_androidid": "ccb8533a2c18827b",
                # "_screen_brightness": "60",
                # "_ukid": "unknown",
                # "_network_type": "UNKOWN",
                # "_deviceid": "5C70287B-27F5-4AC3-9E9C-2D67B8CF1065"

            },
liuxiaoxing committed
159
            'when': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
liuxiaoxing committed
160
            # time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
liuxiaoxing committed
161 162 163 164 165
            # 'ds': ds,
            'who': 'lxx_test'

        })
        try:
liuxiaoxing committed
166
            p = requests.post(url=URL + 'install', data=s, headers=headers, timeout=5)
liuxiaoxing committed
167 168
            # , headers = headers
            print("激活:" + p.text)
liuxiaoxing committed
169
            print("设备id:" + i)
liuxiaoxing committed
170 171 172 173
            print(p.url)
        except Exception as err:
            print(err)

liuxiaoxing committed
174
    # 今日头条归因
liuxiaoxing committed
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
    def formevent(self, i, IP, appkey):
        s = json.dumps({
            "appid": appkey,
            "context": {
                "_campaignid": 'default',
                "_deviceid": i,
                "_imei": i,
                # "_imei2":i,
                # "_oaid":i,
                # "_meid":i,
                "_androidid": "2342312",
                "_ip": IP,
                '_manufacturer': manufacturer,
                '_ryos': ryos,
                '_rydevicetype': rydevicetype,
                '_network': network,
                '_resolution': resolution,
                '_op': op,
                "_lib_version": lv,
                '_timestamp': "aaa"
            },
            # 'when': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
            # time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
            # 'ds': ds,
            'who': 'lxx_test'

        })
liuxiaoxing committed
202
        p = requests.post(url=URL + 'form', data=s, headers=headers, timeout=10)
liuxiaoxing committed
203 204 205
        print("今日头条表单" + p.text)

        # 启动
liuxiaoxing committed
206

liuxiaoxing committed
207 208 209
    def startupEvent(self, i, IP, appkey):
        s = json.dumps(
            {
liuxiaoxing committed
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
                # 'what': 'startup',
                'appid': appkey,
                'context': {
                    '_deviceid': i,
                    '_imei': i,
                    '_androidid': i,
                    '_ip': IP,
                    '_timestamp': current_time_13,
                    "_lib_version": lv,
                    # "current_caid":'2121',
                    # "_campaignid": 'default',
                    # "_deviceid": i,
                    # "_imei": i,
                    # # "_idfa": '75463565745634546',
                    # "_androidid": "424653325643",
                    # # "_imei2":"324323AAAA",
                    # # "_meid": "CCC324323",
                    # "_ip": IP,
                    # # "_ipv6": i,
                    # '_manufacturer': manufacturer,
                    '_ryos': ryos,
                    # '_rydevicetype': rydevicetype,
                    # '_network': network,
                    # '_resolution': resolution,
                    # '_op': op,
                    # '_timestamp': current_time_13,
                    # '_oaid': '999b6e3e-a274-ed22-cebf-2b6dddfc29b7'
                    # # '_mac':"565354131606"
                    'sysfsize': '111',
                    '_model': '1',
                    'sysram': '1',
                    '_ryosversion': '1',
                    'sysutime': '1',
                    'sysuname': '1',
                    '_carrier': '1',
                    'syscountryc': '1',
                    'sysrtime': '1',

                },
                # 'when': when,
                # 'ds': ds,
                'who': 'lxx_test'
liuxiaoxing committed
252 253 254
            }

        )
liuxiaoxing committed
255 256
        p = requests.post(url=URL + 'startup', data=s, headers=headers, timeout=10)
        print("启动" + p.text)
liuxiaoxing committed
257 258
        print(when)

liuxiaoxing committed
259 260
    # 注册
    def registerEvent(self, i, IP, appkey):
liuxiaoxing committed
261 262
        s = json.dumps({
            # 'what':'register',
liuxiaoxing committed
263 264 265 266 267 268 269
            # 标识是否是h5字段
            # "appType": "wap",
            'appid': appkey,
            'context': {
                # "_apptype": "wap",
                '_deviceid': i,
                '_imei': i,
liuxiaoxing committed
270 271
                # "_idfv": i,
                # '_androidid':i,
liuxiaoxing committed
272
                '_ip': IP,
liuxiaoxing committed
273 274 275 276 277 278 279 280 281
                '_timestamp': current_time_13,
                '_oaid': i,
                "_lib_version": lv,

            },
            # 'when': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
            # 'ds': ds,
            'who': 'lxx_test'
        })
liuxiaoxing committed
282 283 284
        p = requests.post(url=URL + 'register', data=s, headers=headers, timeout=10)
        # print("注册时间戳"+current_time_13)
        print("注册" + p.text)
liuxiaoxing committed
285

liuxiaoxing committed
286 287
    # 登陆
    def loginEvent(self, i, IP, appkey):
liuxiaoxing committed
288 289 290
        s = json.dumps({
            # 'what': 'loggedin',
            'appid': appkey,
liuxiaoxing committed
291
            # "appType": "wap",
liuxiaoxing committed
292
            'context': {
liuxiaoxing committed
293
                # "_apptype": "wap",
liuxiaoxing committed
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
                '_deviceid': i,
                # '_imei': i,
                "_idfv": i,
                '_androidid': i,
                '_ip': IP,
                '_ryos': ryos,
                "_lib_version": lv,
                "serverid": "111111",
                # '_rydevicetype': rydevicetype,
                '_timestamp': current_time_13

            },
            # 'when': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
            # 'ds': ds,
            'who': 'lxx_test'
        })
        try:
liuxiaoxing committed
311 312
            p = requests.post(url=URL + 'loggedin', data=s, headers=headers, timeout=10)
            print("登录" + p.text)
liuxiaoxing committed
313 314 315
        except Exception as err:
            print(err)

liuxiaoxing committed
316
    # 付费
liuxiaoxing committed
317

liuxiaoxing committed
318 319
    def payEvent(self, i, IP, appkey):
        # 订单号
liuxiaoxing committed
320 321 322 323 324 325 326 327 328 329 330 331 332 333
        transactionid = ''.join(str(random.choice(range(10))) for _ in range(19))
        s = json.dumps({
            'what': 'payment',
            'appid': appkey,
            'context': {
                '_deviceid': i,
                '_imei': i,
                '_androidid': i,
                '_ip': IP,
                '_timestamp': current_time_13,
                '_transactionid': transactionid,
                '_paymenttype': paymenttype,
                '_ryos': ryos,
                '_currencytype': currencytype,
liuxiaoxing committed
334
                '_currencyamount': currencyamount,
liuxiaoxing committed
335
                "_lib_version": lv,
liuxiaoxing committed
336
                '_oaid': "unknow"
liuxiaoxing committed
337

liuxiaoxing committed
338
            },
liuxiaoxing committed
339 340 341 342
            # 'when': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
            # 'ds': ds,
            'who': 'lxx_test'
        })
liuxiaoxing committed
343 344
        p = requests.post(url=URL + 'payment', data=s, headers=headers, timeout=5)
        print("付费" + p.text)
liuxiaoxing committed
345 346 347
        # print(str(s))

        # 订单
liuxiaoxing committed
348 349

    def payorder(self, i, IP, appkey):
liuxiaoxing committed
350
        # 订单号
liuxiaoxing committed
351 352 353
        # transactionid = ''.join(str(random.choice(range(10))) for _ in range(19))
        transactionid = '765432454364342'

liuxiaoxing committed
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
        s = json.dumps({
            'what': 'order',
            'appid': appkey,
            'context': {
                '_deviceid': i,
                '_imei': i,
                '_androidid': i,
                '_ip': IP,
                '_timestamp': current_time_13,
                '_transactionid': transactionid,
                '_paymenttype': paymenttype,
                "_lib_version": lv,
                '_currencytype': currencytype,
                '_ryos': ryos,
                '_currencyamount': currencyamount,

            },
            # 'when': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
            # 'ds': ds,
            'who': 'lxx_test'
        })
liuxiaoxing committed
375 376
        p = requests.post(url=URL + 'event', data=s, headers=headers, timeout=5)
        print("订单" + p.text)
liuxiaoxing committed
377

liuxiaoxing committed
378 379
    # 自定义事件
    def ziding_event(self, i, IP, appkey, event):
liuxiaoxing committed
380 381
        s = json.dumps({
            'what': event,
liuxiaoxing committed
382 383 384 385
            # h5
            # "appType": "wap",
            # 微信
            # "appType": "wx",
liuxiaoxing committed
386 387
            'appid': appkey,
            'context': {
liuxiaoxing committed
388
                # "_apptype": "wx",
liuxiaoxing committed
389 390 391 392 393 394
                '_deviceid': i,
                '_imei': i,
                '_androidid': i,
                '_ip': IP,
                '_ryos': ryos,
                "_lib_version": lv,
liuxiaoxing committed
395 396 397 398 399 400 401 402 403
                '_key_action_category': '1',
                '_key_action_threshold': '15',
                # 识别是否为自定义事件,默认传1
                '_isreyundefaultevent': '1',
                # 'who': 'lxxtest',
                's': '0',
                'e': '1',
                'm': '2',

liuxiaoxing committed
404 405 406 407 408
            },
            # 'when': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
            # 'ds': ds,
            'who': 'lxx_test'
        })
liuxiaoxing committed
409 410
        p = requests.post(url=URL + 'event', data=s, headers=headers, timeout=5)
        print("自定义" + p.text)
liuxiaoxing committed
411

liuxiaoxing committed
412
    # 自定义事件
liuxiaoxing committed
413 414
    def invoke_test(self, i, IP, appkey):
        s = json.dumps({
liuxiaoxing committed
415 416 417 418
            "what": "invoke",
            "appType": "",
            "appid": appkey,
            "context": {
liuxiaoxing committed
419
                # "_campaignid": "_default_",
liuxiaoxing committed
420 421
                "_rydevicetype": "iPhone",
                "_ip": IP,
liuxiaoxing committed
422
                # '_oaid':'7c5c102b782c33e',
liuxiaoxing committed
423 424 425 426 427 428 429 430
                "_ryosversion": ryosversion,
                "_manufacturer": "苹果",
                "frequency": "0.000",
                "_app_version": "2.0",
                "_isreyundefaultevent": "1",
                "_deviceid": i,
                "_device_gps": "unknown",
                "_jbk": "0",
liuxiaoxing committed
431
                "_timestamp": current_time_13,
liuxiaoxing committed
432 433
                "_imei": i,
                # "_idfa": "DBC43622-E34B-440C-B7A7-FB6641D0D9AB",
liuxiaoxing committed
434
                # "_idfv": i,
liuxiaoxing committed
435 436
                "_lib_version": lv,
                "_carrier": carrier,
liuxiaoxing committed
437 438
                "_ry_ts": current_time_13,
                "_create_timestamp": current_time_13,
liuxiaoxing committed
439 440 441 442 443 444
                "_tz": "+8",
                "_pkgname": "com.reyun.sdktrackingtest",
                "_ipv6": "fe80::1cf8:ea60:3508:1dc2",
                "modify": "0",
                # "_ry_origin_when": "2019-08-16 15:50:09",
                "_resolution": "736*414",
liuxiaoxing committed
445
                "_ryos": "android",
liuxiaoxing committed
446 447 448 449 450
                "_model": model,
                # "_mac": "02:00:00:00:00:00",
                "_network_type": "WIFI",
                # "_androidid": "5432453421342654",
                "_lats": "1"
liuxiaoxing committed
451
            },
liuxiaoxing committed
452 453 454 455
            "where": "event",
            # "when": time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
            # "ds": ds,
            "who": "unknown"
liuxiaoxing committed
456
        })
liuxiaoxing committed
457
        p = requests.post(url=URL + 'event', data=s, headers=headers, timeout=5)
liuxiaoxing committed
458 459
        print("自定义" + p.text)

liuxiaoxing committed
460

liuxiaoxing committed
461
    # 广告展示
liuxiaoxing committed
462
    def adshow(self, i, IP, appkey, adid):
liuxiaoxing committed
463
        s = json.dumps({
liuxiaoxing committed
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486
            "appid": appkey,
            "context": {
                '_adPlatform': adPlatform,
                '_adId': adid,
                "_campaignid": 'default',
                "_deviceid": i,
                "_imei": i,
                # "_idfa": '75463565745634546',
                "_androidid": "424653325643",
                # "_imei2":"324323AAAA",
                # "_meid": "CCC324323",
                "_ip": IP,
                # "_ipv6": i,
                '_manufacturer': manufacturer,
                '_ryos': ryos,
                '_rydevicetype': rydevicetype,
                '_network': network,
                '_resolution': resolution,
                '_op': op,
                '_timestamp': current_time_13,
                '_oaid': '999b6e3e-a274-ed22-cebf-2b6dddfc29b7',
                "_fill": "0",
                # '_mac':"565354131606"
liuxiaoxing committed
487
            },
liuxiaoxing committed
488 489 490
            # 'when': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
            # 'ds': ds,
            'who': 'lxx_test'
liuxiaoxing committed
491 492 493 494 495 496 497 498 499 500

        })
        try:
            p = requests.post(url=URL + 'adshow', data=s, headers=headers, timeout=5)
            print("广告展示:" + p.text)
            print("设备id:" + i)
        except Exception as err:
            print(err)

    # 广告点击
liuxiaoxing committed
501
    def adclick(self, i, IP, appkey, adid):
liuxiaoxing committed
502
        s = json.dumps({
liuxiaoxing committed
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524
            "appid": appkey,
            "context": {
                '_adPlatform': adPlatform,
                '_adId': adid,
                "_campaignid": 'default',
                "_deviceid": i,
                "_imei": i,
                # "_idfa": '75463565745634546',
                "_androidid": "424653325643",
                # "_imei2":"324323AAAA",
                # "_meid": "CCC324323",
                "_ip": IP,
                # "_ipv6": i,
                '_manufacturer': manufacturer,
                '_ryos': ryos,
                '_rydevicetype': rydevicetype,
                '_network': network,
                '_resolution': resolution,
                '_op': op,
                '_timestamp': current_time_13,
                '_oaid': '999b6e3e-a274-ed22-cebf-2b6dddfc29b7'
                # '_mac':"565354131606"
liuxiaoxing committed
525
            },
liuxiaoxing committed
526 527 528
            # 'when': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
            # 'ds': ds,
            'who': 'lxx_test'
liuxiaoxing committed
529 530 531 532 533 534 535 536 537 538 539

        })
        try:
            p = requests.post(url=URL + 'adclick', data=s, headers=headers, timeout=5)
            print("广告点击:" + p.text)
            print("设备id:" + i)
        except Exception as err:
            print(err)

    def retentionEvent(self, i, IP, appkey):
        s = json.dumps(
liuxiaoxing committed
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585
            {
                "what": "retention",
                "appType": "",
                "appid": appkey,
                "context": {
                    "_campaignid": "_default_",
                    "_rydevicetype": "iPhone",
                    "cfnetworkversion": "1197",
                    "sysuname": "E3DB67CAC7AA864C3CBDE118997ADD44",
                    "kernelinfo": "Darwin Kernel Version 20.0.0: Fri Aug 28 23:07:15 PDT 2020; root:xnu-7195.0.46~9/RELEASE_ARM64_T8030",
                    "language": "disable",
                    "_ryosversion": "14.0",
                    "ua": "unknown",
                    "_manufacturer": "苹果",
                    "frequency": "43.667",
                    "_screen_brightness": "0.442",
                    "_isreyundefaultevent": "1",
                    "_timestamp": "1627372876508",
                    "_idfa": "00000000-0000-0000-0000-000000000000",
                    "sysrtime": "disable",
                    "mn": "e2dbe3e4e5eeabe7f3f3",
                    "_carrier": "disable",
                    "_tz": "+8",
                    "_pkgname": "com.reyun.sdktrackingtest",
                    "_ryos": "ios",
                    "_mac": "02:00:00:00:00:00",
                    "hwm": "D421AP", "pbv": "18A373",
                    "_ip": IP,
                    "sysutime": "disable",
                    "_app_version": "2.0",
                    "_deviceid": i,
                    "less_than_fourteen_dev": "00000000-0000-0000-0000-000000000000",
                    "_jbk": "0",
                    "kernosrelease": "20.0.0",
                    "syscountryc": "disable",
                    "ry_appname": "测试iOS",
                    "_idfv": "31199199-4B90-4E10-9D28-3CA815E2B740",
                    "_lib_version": "1.8.6_jsfc",
                    "_ry_ts": "1627372876761",
                    "_create_timestamp": "1627372876508",
                    "_network_type": "WIFI", "_lats": "0"},
                "where": "event",
                "when": when,
                "deviceid": i,
                "ds": when,
                "who": "TA 5-"
liuxiaoxing committed
586 587 588 589 590 591
            })
        p = requests.post(url=URL + 'event', data=s, headers=headers, timeout=10)
        print("retention" + p.text)
        print(when)

        # App页面浏览时长分布
liuxiaoxing committed
592 593

    def pageduration(self, i, IP, appkey, sessionID, pageId):
liuxiaoxing committed
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629
        s = json.dumps({
            "appid": appkey,
            "context": {
                '_pageid': pageId,
                "_sessionid": sessionID,
                '_pageduration': pageduration,
                "_campaignid": 'default',
                "_deviceid": i,
                "_imei": i,
                # "_idfa": '75463565745634546',
                # "_androidid": "424653325643",
                # "_imei2":"324323AAAA",
                # "_meid": "CCC324323",
                "_ip": IP,
                # "_ipv6": i,
                '_manufacturer': manufacturer,
                '_ryos': ryos,
                '_rydevicetype': rydevicetype,
                '_network': network,
                '_resolution': resolution,
                '_op': op,
                '_timestamp': current_time_13,
                '_oaid': '999b6e3e-a274-ed22-cebf-2b6dddfc29b7'
                # '_mac':"565354131606"
            },
            # 'when': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
            # 'ds': ds,
            'who': 'lxx_test'

        })
        try:
            p = requests.post(url=URL + 'pageduration', data=s, headers=headers, timeout=5)
            print("App页面浏览时长分布:" + p.text)
        except Exception as err:
            print(err)

liuxiaoxing committed
630 631
    # App使用时长
    def appduration(self, i, IP, appkey, sessionID):
liuxiaoxing committed
632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665
        s = json.dumps({
            "appid": appkey,
            "context": {
                "_appduration": appduration,
                "_sessionid": sessionID,
                "_campaignid": 'default',
                "_deviceid": i,
                "_imei": i,
                # "_idfa": '75463565745634546',
                # "_androidid": "424653325643",
                # "_imei2":"324323AAAA",
                # "_meid": "CCC324323",
                "_ip": IP,
                # "_ipv6": i,
                '_manufacturer': manufacturer,
                '_ryos': ryos,
                '_rydevicetype': rydevicetype,
                '_network': network,
                '_resolution': resolution,
                '_op': op,
                '_timestamp': current_time_13,
                # '_oaid': '999b6e3e-a274-ed22-cebf-2b6dddfc29b7'
                # '_mac':"565354131606"
            },
            # 'when': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
            # 'ds': ds,
            'who': 'lxx_test'

        })
        try:
            p = requests.post(url=URL + 'appduration', data=s, headers=headers, timeout=5)
            print("App使用时长:" + p.text)
        except Exception as err:
            print(err)
liuxiaoxing committed
666 667

    # 批量上传数据接口
liuxiaoxing committed
668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690
    def batchUpload(self, i, IP, appkey):
        s = json.dumps(
            {"from": "tkio", "data": [
                {"appid": appkey, "when": "2018-01-08 11:22:42", "what": "startup",
                 "context": {"_manufacturer": "苹果", "_carrier": "unknown", "_lats": "1", "_jbk": "1",
                             "_app_version": "1.0", "_timestamp": "1515381771925", "_create_timestamp": "1515381762624",
                             "_rydevicetype": "iPhone", "_deviceid": "FD8A5386-C25B-49D8-A0F3-2E61B179DA0E",
                             "_tz": "+8", "_resolution": "667*375", "_pkgname": "com.reyun.testapp",
                             "_mac": "80:E6:50:12:4C:DE", "_network_type": "NO CONNECT", "_istf": "8",
                             "_idfv": "27CCEE6E-5ED1-47EC-B486-81F9129C05D3", "_ryosversion": "11.2",
                             "_model": "iPhone Simulator", "_lib_version": "2.0.0", "_ryos": "ios",
                             "_campaignid": "channelid", "_idfa": "FD8A5386-C25B-49D8-A0F3-2E61B179DA0E"},
                 "who": "unknown"},
                {"appid": appkey, "when": "2018-01-08 11:22:42", "what": "register",
                 "context": {"_manufacturer": "苹果", "_carrier": "unknown", "_lats": "1", "_jbk": "1",
                             "_app_version": "1.0", "_timestamp": "1515381771925", "_create_timestamp": "1515381762657",
                             "_rydevicetype": "iPhone", "_deviceid": "FD8A5386-C25B-49D8-A0F3-2E61B179DA0E",
                             "_tz": "+8", "_resolution": "667*375", "_pkgname": "com.reyun.testapp",
                             "_mac": "80:E6:50:12:4C:DE", "_network_type": "NO CONNECT", "_istf": "8",
                             "_idfv": "27CCEE6E-5ED1-47EC-B486-81F9129C05D3", "_ryosversion": "11.2",
                             "_model": "iPhone Simulator", "_lib_version": "2.0.0", "_ryos": "ios",
                             "_campaignid": "channelid", "_idfa": "FD8A5386-C25B-49D8-A0F3-2E61B179DA0E"},
                 "who": "acc1"},
liuxiaoxing committed
691
            ]}
liuxiaoxing committed
692 693 694 695 696 697
        )
        p = requests.post(url=URL_batch, data=s, headers=headers, timeout=5)
        print("自定义" + p.text)



liuxiaoxing committed
698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776
# h5下载
    def H5download(self, i, IP, appkey):
        s = json.dumps({
            "what": "download",
            "appType": "wap",
            "appid": appkey,
            "context": {
                # "_campaignid": "_default_",
                "_deviceid": i,
                # "_cid": "-1",
                # "_ry_ts": "1588130655311",
                "_tz": "+8",
                "_ip": IP,
                "_apptype": "wap",
                "_campaignid_bak": "_default_",
                "_ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36",
                "_cid_bak": "-1"
            },
        "where": "event",
        "deviceid": i,
        "when": when,
        "ds": ds,
        "who": "552317006484"
        })
        try:
            p = requests.post(url=URL + 'event', data=s, headers=headers, timeout=5)
            print("download:" + p.text)
        except Exception as err:
            print(err)


# h5pv
    def H5pv(self, i, IP, appkey):
        s = json.dumps({
            "what": "pageview",
            "appType": "wap",
            "appid": appkey,
            "context": {
                # "_campaignid": "_default_",
                "_deviceid": i,
                # "_cid": "-1",
                # "_ry_ts": "1588130655311",
                "_tz": "+8",
                "_ip": IP,
                "_apptype": "wap",
                # "_campaignid_bak": "_default_",
                "_ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36",
                # "_cid_bak": "-1"
            },
        "where": "event",
        "deviceid": i,
        "when": when,
        "ds": ds,
        "who": "552317006484"
        })
        try:
            p = requests.post(url=URL + 'event', data=s, headers=headers, timeout=5)
            print("pv:" + p.text)
        except Exception as err:
            print(err)

        #h5 注册

    def h5registerEvent(self, i, IP, appkey):
        s = json.dumps({
            # 'what':'register',
            # 标识是否是h5字段
            "appType": "wap",
            'appid': appkey,
            'context': {
                "_apptype": "wap",
                '_deviceid': i,
                '_imei': i,
                # "_idfv": i,
                # '_androidid':i,
                '_ip': IP,
                '_timestamp': current_time_13,
                '_oaid': i,
                "_lib_version": lv,
liuxiaoxing committed
777

liuxiaoxing committed
778 779 780 781 782
            },
            # 'when': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
            # 'ds': ds,
            'who': 'lxx_test'
        })
liuxiaoxing committed
783

liuxiaoxing committed
784 785 786
        p = requests.post(url=URL + 'register', data=s, headers=headers, timeout=10)
        # print("注册时间戳"+current_time_13)
        print("注册" + p.text)
liuxiaoxing committed
787

liuxiaoxing committed
788 789
    # 登陆
    def h5loginEvent(self, i, IP, appkey):
liuxiaoxing committed
790
        s = json.dumps({
liuxiaoxing committed
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909
            # 'what': 'loggedin',
            'appid': appkey,
            "appType": "wap",
            'context': {
                "_apptype": "wap",
                '_deviceid': i,
                # '_imei': i,
                "_idfv": i,
                '_androidid': i,
                '_ip': IP,
                '_ryos': ryos,
                "_lib_version": lv,
                "serverid": "111111",
                # '_rydevicetype': rydevicetype,
                '_timestamp': current_time_13

            },
            # 'when': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
            # 'ds': ds,
            'who': 'lxx_test'
        })

        try:
            p = requests.post(url=URL + 'loggedin', data=s, headers=headers, timeout=10)
            print("登录" + p.text)
        except Exception as err:
            print(err)

        # 付费

    def h5payEvent(self, i, IP, appkey):
        # 订单号
        transactionid = ''.join(str(random.choice(range(10))) for _ in range(19))
        s = json.dumps({
            'what': 'payment',
            'appid': appkey,
            "appType": "wap",
            'context': {
                "_apptype": "wap",
                '_deviceid': i,
                '_imei': i,
                '_androidid': i,
                '_ip': IP,
                '_timestamp': current_time_13,
                '_transactionid': transactionid,
                '_paymenttype': paymenttype,
                '_ryos': ryos,
                '_currencytype': currencytype,
                '_currencyamount': currencyamount,
                "_lib_version": lv,
                '_oaid': "unknow"

            },
            # 'when': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
            # 'ds': ds,
            'who': 'lxx_test'
        })

        p = requests.post(url=URL + 'payment', data=s, headers=headers, timeout=5)
        print("付费" + p.text)
        # print(str(s))

            # 订单

    def h5payorder(self, i, IP, appkey):
        # 订单号
        transactionid = ''.join(str(random.choice(range(10))) for _ in range(19))
        s = json.dumps({
            'what': 'order',
            'appid': appkey,
            "appType": "wap",
            'context': {
                "_apptype": "wap",

                '_deviceid': i,
                '_imei': i,
                '_androidid': i,
                '_ip': IP,
                '_timestamp': current_time_13,
                '_transactionid': transactionid,
                '_paymenttype': paymenttype,
                "_lib_version": lv,
                '_currencytype': currencytype,
                '_ryos': ryos,
                '_currencyamount': currencyamount,

            },
            # 'when': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
            # 'ds': ds,
            'who': 'lxx_test'
        })
        p = requests.post(url=URL + 'event', data=s, headers=headers, timeout=5)
        print("订单" + p.text)


# h5
    def H5su(self, i, IP, appkey):
        s = json.dumps({
            "what": "startup",
            "appType": "wap",
            "appid": appkey,
            "context": {
                # "_campaignid": "_default_",
                "_deviceid": i,
                # "_cid": "-1",
                # "_ry_ts": "1588130655311",
                "_tz": "+8",
                "_ip": IP,
                "_apptype": "wap",
                # "_campaignid_bak": "_default_",
                "_ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36",
                # "_cid_bak": "-1"
            },
        "where": "event",
        "deviceid": i,
        "when": when,
        "ds": ds,
        "who": "552317006484"
        })
liuxiaoxing committed
910 911
        try:
            p = requests.post(url=URL + 'event', data=s, headers=headers, timeout=5)
liuxiaoxing committed
912
            print("pv:" + p.text)
liuxiaoxing committed
913 914
        except Exception as err:
            print(err)