API文档

请求参数(Get请求方式传参)

参数 是否必须 参数类型 限制长度 参数说明
appKey yes string 255 接口appKey,应用的唯一标识
uid yes string 255 用户标识,唯一且不可变
credits yes long 20 本次兑换增加的积分
type yes string 40 game(游戏), sign(签到),task(pk赛), reSign(补签),postsale(售后退积分),cancelShip(取消发货-购物车场景下存在),hdtool(加积分活动)所有类型不区分大小写
orderNum yes string 255 兑吧订单号(请记录到数据库中)
subOrderNum no string 255 兑吧子订单号:多个子订单间“,”分隔,例:123,234,345
timestamp yes string 20 1970-01-01开始的时间戳,毫秒为单位。
description no string 255 本次增加积分的描述(带中文,请用utf-8进行url解码)
ip no string 255 用户ip,不保证获取到
sign yes string 255 MD5签名,详见签名规则

响应参数

参数 是否必须 参数类型 限制长度 参数说明
status yes string 255 加积分结果状态,回复ok或者fail
errorMessage no string 255 出错原因
bizId yes string 255 开发者的订单号(唯一且不重复,如果失败该值可以不传)
credits yes long 20 用户积分余额

请使用JSON格式响应

响应示例

成功:
{
 "status":"ok",
 "errorMessage":" ",
 "bizId":"test-20140730192133033",
 "credits":"120"
}
失败:
{
 "status":"fail",
 "errorMessage":"失败原因",
 "credits":"100"
}

代码示例


点击下载(java开发包)

如无法下载,请复制地址浏览器打开:https://github.com/duiba-Tech/duiba-java-sdk/archive/master.zip
/**
     * 加积分充值解析
     * @param request
     * @return
     * @throws Exception
     */
    public AddCreditsParams parseaddCredits(HttpServletRequest request) throws Exception {
        if(!appKey.equals(request.getParameter("appKey"))){
            throw new Exception("appKey不匹配");
        }
        if(request.getParameter("timestamp")==null){
            throw new Exception("请求中没有带时间戳");
        }
        boolean verify=SignTool.signVerify(appSecret, request);
        if(!verify){
            throw new Exception("签名验证失败");
        }
        AddCreditsParams params=new AddCreditsParams();
        params.setAppKey(appKey);
        params.setUid(request.getParameter("uid"));
        params.setCredits(Long.valueOf(request.getParameter("credits")));
        params.setTimestamp(new Date(Long.valueOf(request.getParameter("timestamp"))));
        params.setDescription(request.getParameter("description"));
        params.setOrderNum(request.getParameter("orderNum"));
        params.setType(request.getParameter("type"));
        return params;
    }
2.PHP开发包

【点击下载】

/*
       *  加积分请求的解析方法
        *  返回格式为:
        *  {"status":"ok","credits":"10","bizId":"no123546","errorMessage":""}  或者
        *  {"status":"fail","credits":"10","errorMessage":"余额不足"}
    */
    function parseAddCredits($appKey,$appSecret,$request_array){
        if($request_array["appKey"] != $appKey){
            throw new Exception("appKey not match");
        }
        if($request_array["timestamp"] == null ){
            throw new Exception("timestamp can't be null");
        }
        $verify=signVerify($appSecret,$request_array);
        if(!$verify){
            throw new Exception("sign verify fail");
        }
        $ret=$request_array;
        return $ret;
    }
3.Python开发包

【点击下载】

 # 加积分请求参数解析
    def add_credits(self, request_params):
        if self.appKey != request_params['appKey']:
            raise Exception("appKey not match !")
        elif request_params["timestamp"] == '':
            raise Exception("timestamp can't be null ! ")
        elif self.signVerify(self.appSecret, request_params) == False:
            raise Exception("sign verify fail! ")
        else:
            return request_params

\

更新记录
1.9-17type增加新类型task(PK赛)的类型

1.9-17type字段增加新类型postsale( 售后退积分)

results matching ""

    No results matching ""