game_param.py 4.31 KB
import requests
import json
import time
import random


URL = 'http://log.reyun.com'
# URL = 'http://10.3.20.42:8080'
headers = {'Content-Type': 'application/json'}
URL_install = URL+'/receive/rest/install'
URL_startup = URL+'/receive/rest/startup'
URL_register = URL+'/receive/rest/register'
URL_payment = URL+'/receive/rest/payment'
URL_loggedin = URL+'/receive/rest/loggedin'
URL_event = URL+'/receive/rest/event'
URL_economy = URL+'/receive/rest/economy'

network = 'wifi'
os = 'ios'
devicetype = 'iphone4s'
resolution = '123*456'
channelid = '111'
op = '中国移动'
itemname = '测试5'
itemtotalprice = '99'
serverid = 1
class allevent:
    def event_install(self,i,appid):
        s = json.dumps({
            "appid": appid,
            "context":
                {
                    "deviceid": i,
                    "idfa":i,
                    "idfv":i,
                    "channelid":channelid
                }
        })
        p = requests.post(url=URL_install,data=s,headers=headers,timeout=4)
        print(p.text)
    def event_startup(self,i,appid):
        s = json.dumps({
            "appid": appid,
            "context":
                {
                    "deviceid": i,
                    "idfa":i,
                    "idfv":i,
                    "channelid":channelid,
                    "network":network,
                    "os":os,
                    "devicetype":devicetype,
                    'resolution':resolution,
                    'op': op
                }
        })
        p = requests.post(url=URL_startup,data=s,headers=headers,timeout=4)
        print(p.text)
    def event_register(self,i,appid):
        s = json.dumps({
            "appid": appid,
            "who":i,
            "context":
                {
                    "deviceid": i,
                    #"idfa":i,
                    #"idfv":i,
                    "serverid": serverid,
                    "channelid":channelid
                }
        })
        p = requests.post(url=URL_register, data=s, headers=headers, timeout=4)
        print(p.text)

    def event_login(self, i, appid):
        s = json.dumps({
            "appid": appid,
             "who": i,
            "context":
                {
                    "deviceid": i,
                    # "idfa":i,
                    # "idfv":i,
                    "serverid": serverid,
                    "channelid": channelid
                }
        })
        p = requests.post(url=URL_loggedin,data=s,headers=headers,timeout=4)
        print(p.text)
    def event_payment(self,i,appid,campId):
        s = json.dumps({
            "appid": appid,
            "who":i,
            "context":
                {
                    "deviceid": i,
                    "idfa":i,
                    "idfv":i,
                    "channelid":channelid,
                    "transactionid":"12323232131321",
                    "paymenttype":"支付宝",
                    "currencytype":"CNY",
                    "currencyamount":"100",
                    "virtualcoinamount":"500",
                    "iapname":"test",
                    "iapamount":"3",
                    "campId":campId
                }
        })
        p = requests.post(url=URL_payment,data=s,headers=headers,timeout=4)
        print(p.text)
    def event_event(self,i,appid,event):
        s = json.dumps({
            "appid": appid,
            "who": i,
            "what": event,
            "context":
                {
                    "deviceid": i,
                    # "idfa":i,
                    # "idfv":i,
                    "serverid": serverid,
                    "channelid": channelid
                }
        })
        p = requests.post(url=URL_event, data=s, headers=headers, timeout=4)
        print(p.text)

    def event_economy(self,i,appid,campId):
        s = json.dumps({
            "appid": appid,
            "who":i,
            "context":
                {
                    "deviceid": i,
                    "idfa":i,
                    "idfv":i,
                    "channelid":channelid,
                    "itemamount": "1",
                    "itemname": itemname,
                    "itemtotalprice": itemtotalprice,
                    "campId": campId
                }
        })
        p = requests.post(url=URL_economy,data=s,headers=headers,timeout=4)
        print(p.text)