API文档

版本 V1.0 更新日期 2014.11.22

一、 API接口

二、 API接口参数

三、 API接口使用方法

一、API 接口

API 接口地址:http://www.diaoyanbao.com/thirdparty/load/{唯一链接}

API 接口通信方式:HTTP GET

二、API 接口参数

名称 类型 是否必须 描述
surveyUrl string 问卷的url 地址
uId string 贵方用户UID
appId string 调研宝提供唯一id
appSecret string 调研宝提供唯一secret

三、API 接口使用方法

■ 生成签名sign
base64 加密(surveyURL + uid + App secret)

■ 生成唯一链接
(surveyURL + uid + App id + sign)用逗号拼接后base64 加密

■ 访问url
http://www.diaoyanbao.com/thirdparty/load/{唯一链接}

■ java 代码示范:
1.请先导入commons-codec-1.6.jar
2. public static void main(String[] args) throws NoSuchAlgorithmException {
        // 初始化参数
        String surveyURL = "abcXXX";
        String uid = "123456";
        String appId = "34378216";
        String appSecret = "78UsP4a1i2c";
        // 获取md5 对象
        MessageDigest md = MessageDigest.getInstance("md5");
        try {
                // 对(surveyURL + uid + appSecret) utf8 统一编码
                md.update((surveyURL + uid + appSecret).getBytes("utf-8"));
                byte[] b = md.digest();
                // 生成sign
                String sign = Base64.encodeBase64URLSafeString(b);
                // 输出sign
                System.out.println("[sign]---" + sign);
                // 生成url
                String url = encryptWithBase64(
                                (surveyURL + "," + uid + "," + appId + "," + sign).getBytes()
                        );
                // 输出url
                System.out.println("[url 为]---" + url);
                System.out.println("[解密字符串为]---" + new String(
                                decryptWithBase64(url.getBytes())
                        ));
                System.out.println("[外部访问URL]---" +
                        "http://www.diaoyanbao.com/thirdparty/load/" + url);
        } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
        }
} 通过以上步骤,贵方可以成功的接入调研宝系统,如需获取系统回调请提供回调URL.
回调规则例子: http://www.baidu.com?uid={贵方用户UID}