import requests import json import time import datetime import random from jiami.pdj import encryptorForAES headers = {'Content-Type': 'application/json', } # 'encrypt': '111' # URL = 'https://log.analysis.com/receive/analysis/' URL = 'http://log.tkioglobal.com/receive/tkioglobal/' when = datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S') # when = '2020-02-21 15:50:47' #时间戳 current_time_13 = int(round(time.time() * 1000)) #时间和日期 #日期 ds = time.strftime('%Y-%m-%d', time.localtime(time.time())) #设备品牌 manufacturer = 'HUAWEI' #设备系统 ryos = 'Android' #设备类型 rydevicetype = 'vivox9' #网络类型 network='wifi' #分辨率 resolution='1344*750' #运行商 op ='中国移动' event = 'event1126' # 用户名称标识 user_name = 'lxx' # 用户唯一id(账号id) user_id = '1232432432' # 事件引荐来源 referral_from = 'ceshi' # 付费名称 fufei_name = '付费' # 任何有关游客下单的数据 checkout_as_guest = '13131232121' # 付费商品id content_id = '43123123' # 流水单id,确保唯一 transactionid = '7843584342332' # 货币类型,按照国际标准组织ISO4217中规范的3位大写字母,如USD currencytype = 'CNY' # 付费金额 currencyamount = '66' # 搜索结果 results = '搜索结果 dde wae qweqw edwq eqwe qeqw ' # 搜索内容 uri = "ewr csdfsd we ds dd dasd dsa" # 浏览内容 liulan_name = 'adsdsaadsdasdas' # 完成教程所花费的时间,单位:秒 duration = '31221' class allEvent: # 激活 def installUpload(self, i,IP,appkey,JDClass): s = json.dumps({ "appid": appkey, "what": "install", "who": i, "when":when, "context": { "_deviceid": i, "_androidid": i, # Google play advertising id "_gaid":i, "_mac": "0C:8F:FF:A6:E5:20", "_ip": IP, "_ipv6": "unknown", "_istablet": "phone", "_tz": "+8", "_manufacturer": manufacturer, "_ryos": ryos, "_ryosversion": "6.0", "_rydevicetype": "iPhone", "_model": "DIG-AL00", "_network_type": network, "_resolution": resolution, "_carrier": op, "_device_gps": '43.4209116508', "_audio_volume": '9', "_app_version": "2.0", "_pkgname": "com.example.reyunsdkdemo", "_create_timestamp": current_time_13, "_timestamp": current_time_13, "_lib": "Android", "_screen_brightness": "102", "_lib_version":'1.0' }, }) s = encryptorForAES(s,JDClass) p = requests.post(url=URL+'install', data=s, headers=headers, timeout=10) print("激活:"+p.text) # print(ds) # print(s) # 启动 def startupUpload(self, i,IP,appkey,JDClass): s = json.dumps({ "appid": appkey, "what": "startup", "who": i, "when": when, "context": { "_deviceid": i, "_androidid": i, # Google play advertising id "_gaid": i, "_mac": "0C:8F:FF:A6:E5:20", "_ip": IP, "_app_version": "2.0", "_ryosversion": "6.0", "_create_timestamp": current_time_13, "_timestamp": current_time_13, "_lib": "Android", "_lib_version": '1.0', "_tz": '+8' }, }) s = encryptorForAES(s, JDClass) p = requests.post(url=URL+'startup', data=s, headers=headers, timeout=10) print("启动:"+p.text) # print(p.url) # 注册 def reged(self,i,IP,appkey,JDClass): s = json.dumps({ "appid": appkey, "who": i, "what": "reged", "when":when, "context":{ "_deviceid": i, "_androidid": i, # Google play advertising id "_gaid": i, "_ip": IP, "_app_version": "2.0", "_ryosversion": "6.0", "_create_timestamp": current_time_13, "_timestamp": current_time_13, "_lib": "Android", "_lib_version": '1.0', "_tz": '+8', "user_name": user_name, # 用户唯一id(账号id) "user_id": user_id, # 事件引荐来源 "referral_from": referral_from } }) s = encryptorForAES(s, JDClass) p = requests.post(url=URL+'reged', data=s, headers=headers, timeout=10) print("注册:"+p.text) #登陆 def login(self,i,IP,appkey,JDClass): s = json.dumps({ "appid": appkey, "who": i, "what": "loggedin", "when":when, "context":{ "_deviceid": i, "_androidid": i, # Google play advertising id "_gaid": i, "_ip": IP, "_app_version": "2.0", "_ryosversion": "6.0", "_create_timestamp": current_time_13, "_timestamp": current_time_13, "_lib": "Android", "_lib_version": '1.0', "_tz": '+8', "user_name": user_name, # 用户唯一id(账号id) "user_id": user_id, # 事件引荐来源 "referral_from": referral_from } }) s = encryptorForAES(s, JDClass) p = requests.post(url=URL+'loggedin', data=s, headers=headers, timeout=10) print("登陆:"+p.text) # 付费 def payment(self,i,IP,appkey,JDClass): s = json.dumps({ "appid": appkey, "who": i, "what": "payment", "when":when, "context":{ "_deviceid": i, "_androidid": i, # Google play advertising id "_gaid": i, "_ip": IP, "_app_version": "2.0", "_ryosversion": "6.0", "_create_timestamp": current_time_13, "_timestamp": current_time_13, "_lib": "Android", "_lib_version": '1.0', "_tz": '+8', # 用户唯一id(账号id) "user_id": user_id, "name": fufei_name, "user_id":user_id, "checkout_as_guest":checkout_as_guest, "content_id":content_id, "_transactionid":transactionid, "_currencytype":currencytype, "_currencyamount":currencyamount } }) s = encryptorForAES(s, JDClass) p = requests.post(url=URL+'payment', data=s, headers=headers, timeout=10) print("付费:"+p.text) # 订单 def order(self,i,IP,appkey,JDClass): s = json.dumps({ "appid": appkey, "who": i, "what": "order", "context":{ "_deviceid": i, "_androidid": i, # Google play advertising id "_gaid": i, "_ip": IP, "_app_version": "2.0", "_ryosversion": "6.0", "_create_timestamp": current_time_13, "_timestamp": current_time_13, "_lib": "Android", "_lib_version": '1.0', "_tz": '+8', # 用户唯一id(账号id) "user_id": user_id, "name": fufei_name, "checkout_as_guest":checkout_as_guest, "content_id":content_id, "_transactionid":transactionid, "_currencytype":currencytype, "_currencyamount":currencyamount } }) s = encryptorForAES(s, JDClass) p = requests.post(url=URL+'order', data=s, headers=headers, timeout=10) print("订单:"+p.text) # 订阅 def subscribe(self,i,IP,appkey,JDClass): s = json.dumps({ "appid": appkey, "who": i, "what": "subscribe", "context": { "_deviceid": i, "_androidid": i, # Google play advertising id "_gaid": i, "_ip": IP, "_app_version": "2.0", "_ryosversion": "6.0", "_create_timestamp": current_time_13, "_timestamp": current_time_13, "_lib": "Android", "_lib_version": '1.0', "_tz": '+8', # 用户唯一id(账号id) "user_id": user_id, "name": fufei_name, "checkout_as_guest":checkout_as_guest, "content_id":content_id, "_transactionid":transactionid, "_currencytype":currencytype, "_currencyamount":currencyamount } }) s = encryptorForAES(s, JDClass) p = requests.post(url=URL+'subscribe', data=s, headers=headers, timeout=10) print("订阅:"+p.text) # 搜索 def search(self,i,IP,appkey,JDClass): s = json.dumps({ "appid": appkey, "who": i, "what": "search", "when": when, "context": { "_deviceid": i, "_androidid": i, # Google play advertising id "_gaid": i, "_ip": IP, "_app_version": "2.0", "_ryosversion": "6.0", "_create_timestamp": current_time_13, "_timestamp": current_time_13, "_lib": "Android", "_lib_version": '1.0', "_tz": '+8', "uri": uri, "results": results } }) s = encryptorForAES(s, JDClass) p = requests.post(url=URL+'search', data=s, headers=headers, timeout=10) print("搜索:"+p.text) # 统计浏览 def view(self,i,IP,appkey,JDClass): s = json.dumps({ "appid": appkey, "who": i, "what": "view", "when": when, "context": { "_deviceid": i, "_androidid": i, # Google play advertising id "_gaid": i, "_ip": IP, "_app_version": "2.0", "_ryosversion": "6.0", "_create_timestamp": current_time_13, "_timestamp": current_time_13, "_lib": "Android", "_lib_version": '1.0', "_tz": '+8', "user_id": user_id, "name": liulan_name, "referral_from": referral_from, "content_id":content_id } }) s = encryptorForAES(s, JDClass) p = requests.post(url=URL+'view', data=s, headers=headers, timeout=10) print("浏览:"+p.text) # 统计统计加入购物车 def addtocart(self,i,IP,appkey,JDClass): s = json.dumps({ "appid": appkey, "who": i, "what": "addtocart", "when": when, "context": { "_deviceid": i, "_androidid": i, # Google play advertising id "_gaid": i, "_ip": IP, "_app_version": "2.0", "_ryosversion": "6.0", "_create_timestamp": current_time_13, "_timestamp": current_time_13, "_lib": "Android", "_lib_version": '1.0', "_tz": '+8', "user_id": user_id, "name": liulan_name, "referral_from": referral_from, "content_id":content_id } }) s = encryptorForAES(s, JDClass) p = requests.post(url=URL+'addtocart', data=s, headers=headers, timeout=10) print("加入购物车:"+p.text) # 统计加入愿望清单(收藏) def addtowishlist(self,i,IP,appkey,JDClass): s = json.dumps({ "appid": appkey, "who": i, "what": "addtowishlist", "when": when, "context": { "_deviceid": i, "_androidid": i, # Google play advertising id "_gaid": i, "_ip": IP, "_app_version": "2.0", "_ryosversion": "6.0", "_create_timestamp": current_time_13, "_timestamp": current_time_13, "_lib": "Android", "_lib_version": '1.0', "_tz": '+8', "user_id": user_id, "name": liulan_name, "referral_from": referral_from, "content_id":content_id } }) s = encryptorForAES(s, JDClass) p = requests.post(url=URL+'addtowishlist', data=s, headers=headers, timeout=10) print("加入愿望清单:"+p.text) # 统计完成教程 def tutorialcomplete(self,i,IP,appkey,JDClass): s = json.dumps({ "appid": appkey, "who": i, "what": "tutorialcomplete", "when": when, "context": { "_deviceid": i, "_androidid": i, # Google play advertising id "_gaid": i, "_ip": IP, "_app_version": "2.0", "_ryosversion": "6.0", "_create_timestamp": current_time_13, "_timestamp": current_time_13, "_lib": "Android", "_lib_version": '1.0', "_tz": '+8', "user_id": user_id, "name": liulan_name, "duration": duration } }) s = encryptorForAES(s, JDClass) p = requests.post(url=URL+'tutorialcomplete', data=s, headers=headers, timeout=10) print("完成教程:"+p.text) # 统计等级达成 def levelcomplete(self, i, IP, appkey, JDClass): s = json.dumps({ "appid": appkey, "who": i, "what": "levelcomplete", "when": when, "context": { "_deviceid": i, "_androidid": i, # Google play advertising id "_gaid": i, "_ip": IP, "_app_version": "2.0", "_ryosversion": "6.0", "_create_timestamp": current_time_13, "_timestamp": current_time_13, "_lib": "Android", "_lib_version": '1.0', "_tz": '+8', "user_id": user_id, "name": liulan_name, "duration": duration } }) s = encryptorForAES(s, JDClass) p = requests.post(url=URL + 'levelcomplete', data=s, headers=headers, timeout=10) print("等级达成:"+p.text) # 统计成就达成 def achievement(self, i, IP, appkey, JDClass): s = json.dumps({ "appid": appkey, "who": i, "what": "achievement", "when": when, "context": { "_deviceid": i, "_androidid": i, # Google play advertising id "_gaid": i, "_ip": IP, "_app_version": "2.0", "_ryosversion": "6.0", "_create_timestamp": current_time_13, "_timestamp": current_time_13, "_lib": "Android", "_lib_version": '1.0', "_tz": '+8', "user_id": user_id, "name": liulan_name, "duration": duration } }) s = encryptorForAES(s, JDClass) p = requests.post(url=URL + 'achievement', data=s, headers=headers, timeout=10) print("成就达成:"+p.text) # 统计广告点击 def adclick(self, i, IP, appkey, JDClass): s = json.dumps({ "appid": appkey, "who": i, "what": "adclick", "when": when, "context": { "_deviceid": i, "_androidid": i, # Google play advertising id "_gaid": i, "_ip": IP, "_app_version": "2.0", "_ryosversion": "6.0", "_create_timestamp": current_time_13, "_timestamp": current_time_13, "_lib": "Android", "_lib_version": '1.0', "_tz": '+8', "ad_type": "激励视频", "ad_network_name": "广告平台名称", "placement": "广告位" } }) s = encryptorForAES(s, JDClass) p = requests.post(url=URL + 'adclick', data=s, headers=headers, timeout=10) print("点击广告:"+p.text) # 统计广告观看 def adview(self, i, IP, appkey, JDClass): s = json.dumps({ "appid": appkey, "who": i, "what": "adview", "when": when, "context": { "_deviceid": i, "_androidid": i, # Google play advertising id "_gaid": i, "_ip": IP, "_app_version": "2.0", "_ryosversion": "6.0", "_create_timestamp": current_time_13, "_timestamp": current_time_13, "_lib": "Android", "_lib_version": '1.0', "_tz": '+8', "ad_type": "激励视频", "ad_network_name": "广告平台名称", "placement": "广告位" } }) s = encryptorForAES(s, JDClass) p = requests.post(url=URL + 'adview', data=s, headers=headers, timeout=10) print("广告观看:"+p.text) # 统计评分 def rating(self, i, IP, appkey, JDClass): s = json.dumps({ "appid": appkey, "who": i, "what": "rating", "when": when, "context": { "_deviceid": i, "_androidid": i, # Google play advertising id "_gaid": i, "_ip": IP, "_app_version": "2.0", "_ryosversion": "6.0", "_create_timestamp": current_time_13, "_timestamp": current_time_13, "_lib": "Android", "_lib_version": '1.0', "_tz": '+8', "rating_value": "30", "max_rating_value": "89", } }) s = encryptorForAES(s, JDClass) p = requests.post(url=URL + 'rating', data=s, headers=headers, timeout=10) print("评分:"+p.text) def rating(self, i, IP, appkey, JDClass): s = json.dumps({ "appid": "xxxxxxxxxxxxxxxx", "who": "88DF8986-6E80-4B6D-8CD0-DBB402A80D18", "what": "custom_eventname1", "when": "2019-09-16 21:28:58", "context": { "_timestamp": "1570636195286", "_app_version": "1.2.0", "_idfv": "11288275-88C7-4880-8F86-485BE1AE88BB", "_create_timestamp": "1570636195286", "_idfa": "88DF8986-6E80-4B6D-8CD0-DBB402A80D18", "_lib": "iOS", "_lib_version": "a1.0.0", "_deviceid": "88DF8986-6E80-4B6D-8CD0-DBB402A80D18", "_ip": "1.1.1.1", "_ryosversion": "13.0.1", "_tz": "+8", "custom_param1": "custom_value1", "custom_param3": "custom_value3" } }) s = encryptorForAES(s, JDClass) p = requests.post(url=URL + 'rating', data=s, headers=headers, timeout=10) print("评分:" + p.text) # 统计事件 # def rating(self, i, IP, appkey,event, JDClass): # s = json.dumps({ # "appid": appkey, # "who": i, # "what": event, # "when": when, # "context": { # "_deviceid": i, # "_androidid": i, # # Google play advertising id # "_gaid": i, # "_ip": IP, # "_app_version": "2.0", # "_ryosversion": "6.0", # "_create_timestamp": current_time_13, # "_timestamp": current_time_13, # "_lib": "Android", # "_lib_version": '1.0', # "_tz": '+8', # "name": fufei_name, # "user_id": user_id, # "checkout_as_guest": checkout_as_guest, # "content_id": content_id, # "_currencytype": currencytype, # "_currencyamount": currencyamount # } # }) # s = encryptorForAES(s, JDClass) # p = requests.post(url=URL + 'rating', data=s, headers=headers, timeout=10)