android_script.py 7.44 KB
import requests
import json
import time
import random

from jiami.pdj import encryptorForAES

headers = {'Content-Type': 'application/json'}


# URL = 'https://log.analysis.com/receive/analysis/'

URL = 'http://119.3.252.134/receive/analysis/'


#时间戳
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 = 'HUAWEI'
#设备系统
ryos = 'Android'
#设备类型
rydevicetype = 'vivox9'
#网络类型
network='wifi'
#分辨率
resolution='1344*750'
#运行商
op='中国移动'
channelid = 'aaa'
event = 'event1126'
page = 'page_26'
session = '3224232'

class allEvent:
    # 激活
    def installUpload(self, i,IP,appkey,JDClass):
        s = json.dumps({
	        "appid": appkey,
            "ds": ds,
            "what": "install",
            "where": "install",
            "who": i,
	        "context": {
                "_manufacturer": manufacturer,
                "_istablet": "phone",
                "_network_type": network,
                "_timestamp": current_time_13,
                "_ipv6": "unknown",
                "_tz": "+8",
                "_ry_ts": "1572490307682",
                "_pkgname": "com.example.reyunsdkdemo",
                "_audio_volume": "0",
                "_app_version": "2.0",
                # "_ry_origin_when": "2019-10-31 10:51:48",
                "_model": "DIG-AL00",
                "_ip": IP,
                "_lib": "Android",
                "_androidid": i,
                "_mac": "0C:8F:FF:A6:E5:20",
                "_ryos": ryos,
                "_oaid": "fd95eefb-abe9-4fa5-efe5-3f9b5bfd0128",
                "_ryosversion": "6.0",
                "_imei": i,
                "_resolution": resolution,
                # "_region": "北京",
                "_lib_version": "a1.0.0",
                "_rydevicetype": "DIG-AL00",
                "_deviceid": i,
                "_carrier": "unknown",
                "_screen_brightness": "102",
                "_channelid": channelid
            },

        })

        s = encryptorForAES(s,JDClass)
        p = requests.post(url=URL+'install', data=s, headers=headers, timeout=10)
        print("激活:"+p.text)
        # print(ds)
        # print(p.url)
    # 启动
    def startupUpload(self, i,IP,appkey,JDClass):
        s = json.dumps({
	        "appid": appkey,
            "ds": ds,
            "what": "startup",
            "where": "startup",
            "who": i,
	        "context": {
                "_manufacturer": manufacturer,
                "_istablet": "phone",
                "_network_type": network,
                "_timestamp": current_time_13,
                "_ipv6": "unknown",
                "_tz": "+8",
                "_ry_ts": "1572490307682",
                "_pkgname": "com.example.reyunsdkdemo",
                "_audio_volume": "0",
                "_app_version": "2.0",
                # "_ry_origin_when": "2019-10-31 10:51:48",
                "_model": "DIG-AL00",
                "_ip": IP,
                "_lib": "Android",
                "_androidid": i,
                "_mac": "0C:8F:FF:A6:E5:20",
                "_ryos": ryos,
                "_oaid": "fd95eefb-abe9-4fa5-efe5-3f9b5bfd0128",
                "_ryosversion": "6.0",
                "_imei": i,
                "_resolution": resolution,
                # "_region": "北京",
                "_lib_version": "a1.0.0",
                "_rydevicetype": "DIG-AL00",
                "_deviceid": i,
                "_carrier": "unknown",
                "_screen_brightness": "102",
                "_channelid": channelid
            },

        })

        s = encryptorForAES(s, JDClass)
        p = requests.post(url=URL+'startup', data=s, headers=headers, timeout=10)
        print("启动:"+p.text)
        # print(p.url)
    # 事件
    def eventUpload(self, i, IP, appkey,interface_type,JDClass):
        s =json.dumps({
            "appid": appkey,
            "context": {
                "_ry_origin_when": when,
                "_idfv": "0B7B677B-47C6-4615-B938-983EB8C09B28",
                "_ip": IP,
                "_lib": "iOS",
                "_session": session,
                "_interface_type": interface_type,
                "_timestamp": current_time_13,
                "_create_timestamp": time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
                "_imei": i,
                "_androidid": i,
                "_mac": "0C:8F:FF:A6:E5:20",
                "_oaid": "fd95eefb-abe9-4fa5-efe5-3f9b5bfd0128",
                "_lib_version": "a1.0.0",
                "_deviceid": i,
                "_tz": "+8",
                "_channelid": channelid,
                "_ry_ts": "1572335394441",
                "_app_version": "1.0"
            },
            "ds": ds,
            "what": event,
            "where": 'event',
            "who": i
        })
        s = encryptorForAES(s,JDClass)
        p = requests.post(url=URL + 'event', data=s, headers=headers, timeout=10)
        print("事件:" + p.text)
        # print(p.url)
    # page
    def pageUpload(self, i, IP, appkey,interface_type,JDClass):
        s = json.dumps({
	        "appid": appkey,
            "ds": ds,
            "what": page,
            "where": "page",
            "who": i,
	        "context": {
                "_idfv": i,
                "_ip":IP,
                "_lib": "Android",
                "_batch_type": "pagebatch",
                "_session": session,
                "_interface_type": interface_type,
                "_timestamp": current_time_13,
                "_create_timestamp": time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
                "_imei": i,
                "_androidid": i,
                "_mac": "0C:8F:FF:A6:E5:20",
                "_oaid": "fd95eefb-abe9-4fa5-efe5-3f9b5bfd0128",
                "_lib_version": "a1.0.0",
                "_deviceid": i,
                "_tz": "+8",
                "_channelid": channelid,
                "_ry_ts": "1572342341972",
                "_app_version": "1.0"
	        },
        })
        s = encryptorForAES(s,JDClass)
        p = requests.post(url=URL + 'page', data=s, headers=headers, timeout=10)
        print("page:" + p.text)
        # print(p.url)


    # 退出
    def exitUpload(self, i, IP, appkey,JDClass):
        s = json.dumps({
	        "appid": appkey,
            "ds": ds,
            "what": "exit",
            "who": i,
	        "context": {
                "_ry_origin_when": when,
                "_triger": "terminate",
                "_idfv": i,
                "_ip": IP,
                "_exit_page": page,
                "_lib": "Android",
                "_session": session,
                "_timestamp": current_time_13,
                "_create_timestamp": time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
                "_imei": i,
                "_androidid": i,
                "_mac": "0C:8F:FF:A6:E5:20",
                "_oaid": "fd95eefb-abe9-4fa5-efe5-3f9b5bfd0128",
                "_lib_version": "a1.0.0",
                "_deviceid": i,
                "_tz": "+8",
                "_channelid": channelid,
                "_ry_ts": "1572343547238",
                "_app_version": "1.0"
	        },

        })
        s = encryptorForAES(s,JDClass)
        p = requests.post(url=URL + 'exit', data=s, headers=headers, timeout=10)
        print("退出:" + p.text)
        # print(p.url)