流量充值解决方案(附代码)

来源:互联网 发布:便签元数据修复 编辑:程序博客网 时间:2024/04/28 13:54

流量充值服务

在一个API平台找到了流量充值服务,http://www.apix.cn/services/show/164,感觉对接还比较容易,价格也比许多平台便宜,顺便给大家推荐一下。希望不要当做广告。下面讲一下方法,图片是产品介绍界面。


注册账号后,就可以免费申请使用服务。服务一共有6个接口,每个接口都有对应的功能。如果要完成充值,还需要再平台账户储值,然后每次充值都是根据报价,从账户金额中扣除。充流量貌似是可以开发票的。

1,查询全部流量套餐

返回所有支持套餐的价格

import requestsurl = "http://p.apix.cn/apixlife/pay/mobile/allpackage"headers = {    'accept': "application/json",    'content-type': "application/json",    'apix-key': "您的apix-key"    }response = requests.request("GET", url, headers=headers)print(response.text)

2,查询号码支持的流量套餐

根据号码查询能否充值流量。

import requestsurl = "http://p.apix.cn/apixlife/pay/mobile/package"querystring = {"phone":"18512345678"}headers = {    'accept': "application/json",    'content-type': "application/json",    'apix-key': "您的apix-key"    }response = requests.request("GET", url, headers=headers, params=querystring)print(response.text)

{    "Code": 0,    "Msg": "成功",    "Data": {        "ProviderId": 2,        "ProviderName": "中国联通",        "UserDataPackages": [{            "PkgId": 1,            "DataValue": "20M",            "Price": 3,            "Cost": 2.95,            "Scope": 2,            "LimitTimes": "5",            "Support4G": 1,            "EffectStartTime": 1,            "EffectTime": 1        },        {            "PkgId": 2,            "DataValue": "50M",            "Price": 6,            "Cost": 5.85,            "Scope": 2,            "LimitTimes": "5",            "Support4G": 1,            "EffectStartTime": 1,            "EffectTime": 1        },        {            "PkgId": 3,            "DataValue": "100M",            "Price": 10,            "Cost": 9.8,            "Scope": 2,            "LimitTimes": "5",            "Support4G": 1,            "EffectStartTime": 1,            "EffectTime": 1        },        {            "PkgId": 4,            "DataValue": "200M",            "Price": 15,            "Cost": 14.5,            "Scope": 2,            "LimitTimes": "5",            "Support4G": 1,            "EffectStartTime": 1,            "EffectTime": 1        },        {            "PkgId": 5,            "DataValue": "500M",            "Price": 30,            "Cost": 28.9,            "Scope": 2,            "LimitTimes": "5",            "Support4G": 1,            "EffectStartTime": 1,            "EffectTime": 1        },        {            "PkgId": 6,            "DataValue": "1G",            "Price": 100,            "Cost": 97,            "Scope": 2,            "LimitTimes": "当天2个,6个月内10个",            "Support4G": 1,            "EffectStartTime": 1,            "EffectTime": 3        }]    }}


3,流量充值接口

这是最核心的充值接口,调用后可以完成充值。但是

import requestsurl = "http://p.apix.cn/apixlife/pay/mobile/data_recharge"querystring = {"phone":"your_value","pkgid":"1","orderid":"ACX2014443393755","sign":"MD5加密的值","callback_url":"回调URL,可不填"}headers = {    'accept': "application/json",    'content-type': "application/json",    'apix-key': "您的apix-key"    }response = requests.request("GET", url, headers=headers, params=querystring)print(response.text)

除了,上面三个核心充值接口,还有订单状态查询接口,历史订单记录,账户余额等。平台对充值服务,还有在线调试和统计分析功能,用户只需要页面操作无需变成,也可以完成充值。很赞。



0 0
原创粉丝点击