资源描述:
《基于python的游戏app充值api调用代码实例 》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、基于Python的游戏app充值api调用代码实例代码描述:基于Python的游戏app充值api调用代码实例代码平台:聚合数据#!/usr/bin/python#-*-coding:utf-8importjson,urllibfromurllibimporturlencode##游戏充值调用示例代码一聚合数据#在线接门文档:http://www.juhe.cn/docs/88#defmain():#配置您申请的APPKeygppkey=11*********************11#1.商品小类列表requestl(appkey,"GET")#2.商品信息
2、request2(appkey,"GET")#3.商品价格查询request3(appkey,"GET")#4.游戏直充区服查询request4(appkey)"GET")#5.游戏直充requests(appkey,nGET")#6.订单状态查询request6(appkey/’GET")#商品小类列表defrequestl(appkey,m="GET"):url=nhttp://op.juhe.cn/ofpay/game/cardlistparams={key":appkey,#应用APPKEY(应用详细页査询)}params=urlencode(param
3、s)ifm=="GETf=urllib.urlopen("%s?%sH%(url,params))else:f=urllib.urlopen(url>params)content=f.read()res=jsoruloads(content)ifres:error_code=res[nerror_coden]iferror_code==0:#成功请求printres["result"]else:printn%s:%sH%(res[nerror_coden],res[nreasonM])else:print"requestapierror11#商品信息defreq
4、uest2(appkey,m=’’GET"):url=nhttp://op.juhe.cn/ofpay/game/cardinfoparams={cardid":对应接口1的cardidkey":appkey,#应用APPKEY(应用详细页查询)}params=urlencode(params)ifm=="GETf=urllib.urlopen(,,%s?%sH%(url,params))else:f=urllib.urlopen(url>params)content=f•read()res=json.loads(content)ifres:error_code
5、=res[’’error_coden]iferror_code==0:#成功请求printres["result"]else:print”%s:%s”%(res["error_coden],res["reason"])else:print"requestapierror11#商品价格查询defrequest3(appkey,m="GET"):url=Hhttp://opcn/ofpay/game/cardprice1'params={"cardid":#对应接门2的cardid"key":appkey,#应用APPKEY(应用详细页查询)}param
6、s=urlencode(params)ifm=="GET":f=urllib.urlopen("%s?%s"%(url,params))else:f=urllib•urlopen(url,params)content=f.read()res=json.loads(content)ifres:error_code=res[f,error_coden]iferror_code==0:#成功请求printres["result"]else:print,,%s:%sH%(res[nerror_code'1],res["reason11])else:print"reque
7、stapierror"#游戏直充区服查询defrequest4(appl〈ey,m="GET"):url="http://op.juhe.cn/ofpay/game/areaserver■■params={"cardid":对应接口3的cardid"key":appkey,#应用APPKEY(应用详细页查询)}params:urlencode(params)ifm=="GETf=urllib.urlopen(,,%s?%s"%(url,params))else:f=urllib.urlopen(url,params)content=f.read()res=jso
8、ruloads(cont