商品分类
车型大全
最新最全的车型车系大全、汽车标志大全。1级为车品牌,2级为车品牌子公司,3级为车型,4级为具体的车款。
价格
¥10

1人在使用

交付方式
API交付

提供API调用额度和鉴权信息

使用期限

优质服务商家

7*8小时在线客服

专业测试保证品质

API文档

车型搜索

调用地址:https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/search

请求方式:GET

返回类型:HTML

API调用: API调用说明(secret_id & secret_key)

请求参数(Headers)

名称
类型
是否必须
描述
暂无数据

请求参数(Query)

名称
类型
是否必须
描述
keyword
string
关键词

请求参数(Body)

名称
类型
是否必须
描述
暂无数据

请求示例

# -*- coding: utf-8 -*-
from __future__ import print_function

import ssl, hmac, base64, hashlib
from datetime import datetime as pydatetime

try:
    from urllib import urlencode
    from urllib2 import Request, urlopen
except ImportError:
    from urllib.parse import urlencode
    from urllib.request import Request, urlopen

# 云市场分配的密钥Id
secretId = "xxxx"
# 云市场分配的密钥Key
secretKey = "xxxx"
source = "market"

# 签名
datetime = pydatetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT')
signStr = "x-date: %s\nx-source: %s" % (datetime, source)
sign = base64.b64encode(hmac.new(secretKey.encode('utf-8'), signStr.encode('utf-8'), hashlib.sha1).digest())
auth = 'hmac id="%s", algorithm="hmac-sha1", headers="x-date x-source", signature="%s"' % (secretId, sign.decode('utf-8'))

# 请求方法
method = 'GET'
# 请求头
headers = {
    'X-Source': source,
    'X-Date': datetime,
    'Authorization': auth,
}
# 查询参数
queryParams = {
    'keyword': '奥迪'}
# body参数(POST方法下存在)
bodyParams = {
}
# url参数拼接
url = 'https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/search'
if len(queryParams.keys()) > 0:
    url = url + '?' + urlencode(queryParams)

request = Request(url, headers=headers)
request.get_method = lambda: method
if method in ('POST', 'PUT', 'PATCH'):
    request.data = urlencode(bodyParams).encode('utf-8')
    request.add_header('Content-Type', 'application/x-www-form-urlencoded')
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
response = urlopen(request, context=ctx)
content = response.read()
if content:
    print(content.decode('utf-8'))
curl -v -X GET https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/search ?keyword=奥迪-H 'Host:service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com' -H 'Source:source' -H 'Date:Mon, 19 Mar 2018 12:08:40 GMT' -H 'Authorization:hmac id = "AKIDi6qE41WgJ9w8h4h9zq68Vq24d1beIuN0qIwU", algorithm = "hmac-sha1", headers = "date source", signature = yMCxXNytW5nvVGNZ8aBtRxmiLJ4=' -H 'X-Requested-With:XMLHttpRequest' 
//请用云市场分配给您的密钥计算签名并放入请求头,Date为当前的GMT时间
<?php
// 云市场分配的密钥Id
$secretId = 'xxxx';
// 云市场分配的密钥Key
$secretKey = 'xxxx';
$source = 'market';

// 签名
$datetime = gmdate('D, d M Y H:i:s T');
$signStr = sprintf("x-date: %s\nx-source: %s", $datetime, $source);
$sign = base64_encode(hash_hmac('sha1', $signStr, $secretKey, true));
$auth = sprintf('hmac id="%s", algorithm="hmac-sha1", headers="x-date x-source", signature="%s"', $secretId, $sign);

// 请求方法
$method = 'GET';
// 请求头
$headers = array(
    'X-Source' => $source,
    'X-Date' => $datetime,
    'Authorization' => $auth,
);
// 查询参数
$queryParams = array (
    'keyword' => '奥迪',
);
// body参数(POST方法下)
$bodyParams = array (
);
// url参数拼接
$url = 'https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/search';
if (count($queryParams) > 0) {
    $url .= '?' . http_build_query($queryParams);
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_HTTPHEADER, array_map(function ($v, $k) {
    return $k . ': ' . $v;
}, array_values($headers), array_keys($headers)));
if (in_array($method, array('POST', 'PUT', 'PATCH'), true)) {
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($bodyParams));
}

$data = curl_exec($ch);
if (curl_errno($ch)) {
    echo "Error: " . curl_error($ch);
} else {
    print_r($data);
}
curl_close($ch);
/**
 * npm install crypto-js request
 */
var CryptoJS = require("crypto-js");
var request = require('request');
var querystring = require('querystring');

// 云市场分配的密钥Id
var secretId = "xxx";
// 云市场分配的密钥Key
var secretKey = "xxx";
var source = "market";

// 签名
var datetime = (new Date()).toGMTString();
var signStr = "x-date: " + datetime + "\n" + "x-source: " + source;
var sign = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA1(signStr, secretKey))
var auth = 'hmac id="' + secretId + '", algorithm="hmac-sha1", headers="x-date x-source", signature="' + sign + '"';

// 请求方法
var method = 'GET';
// 请求头
var headers = {
    "X-Source": source,
    "X-Date": datetime,
    "Authorization": auth,
}
// 查询参数
var queryParams = {
    'keyword': '奥迪'}
// body参数(POST方法下)
var bodyParams = {
}
// url参数拼接
var url = 'https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/search';
if (Object.keys(queryParams).length > 0) {
    url += '?' + querystring.stringify(queryParams);
}

var options = {
    url: url,
    timeout: 5000,
    method: method,
    headers: headers
}
if (['POST', 'PUT', 'PATCH'].indexOf(method) != -1) {
    options['body'] = querystring.stringify(bodyParams);
    options['headers']['Content-Type'] = "application/x-www-form-urlencoded";
}

request(options, function (error, response, body) {
    if (error !== null) {
        console.log('error:', error);
        return;
    }
    console.log(body);
});
package main

import (
    "crypto/hmac"
    "crypto/sha1"
    "encoding/base64"
    "fmt"
    "io"
    "io/ioutil"
    "net/http"
    gourl "net/url"
    "strings"
    "time"
)

func calcAuthorization(source string, secretId string, secretKey string) (auth string, datetime string, err error) {
    timeLocation, _ := time.LoadLocation("Etc/GMT")
    datetime = time.Now().In(timeLocation).Format("Mon, 02 Jan 2006 15:04:05 GMT")
    signStr := fmt.Sprintf("x-date: %s\nx-source: %s", datetime, source)

    // hmac-sha1
    mac := hmac.New(sha1.New, []byte(secretKey))
    mac.Write([]byte(signStr))
    sign := base64.StdEncoding.EncodeToString(mac.Sum(nil))

    auth = fmt.Sprintf("hmac id=\"%s\", algorithm=\"hmac-sha1\", headers=\"x-date x-source\", signature=\"%s\"",
        secretId, sign)

    return auth, datetime, nil
}

func urlencode(params map[string]string) string {
    var p = gourl.Values{}
    for k, v := range params {
        p.Add(k, v)
    }
    return p.Encode()
}

func main() {
    // 云市场分配的密钥Id
    secretId := "xxxx"
    // 云市场分配的密钥Key
    secretKey := "xxxx"
    source := "market"

    // 签名
    auth, datetime, _ := calcAuthorization(source, secretId, secretKey)

    // 请求方法
    method := "GET"
    // 请求头
    headers := map[string]string{"X-Source": source, "X-Date": datetime, "Authorization": auth}

    // 查询参数
    queryParams := make(map[string]string)
    queryParams["keyword"] = "奥迪"
    // body参数
    bodyParams := make(map[string]string)

    // url参数拼接
    url := "https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/search"
    if len(queryParams) > 0 {
        url = fmt.Sprintf("%s?%s", url, urlencode(queryParams))
    }

    bodyMethods := map[string]bool{"POST": true, "PUT": true, "PATCH": true}
    var body io.Reader = nil
    if bodyMethods[method] {
        body = strings.NewReader(urlencode(bodyParams))
        headers["Content-Type"] = "application/x-www-form-urlencoded"
    }

    client := &http.Client{
        Timeout: 5 * time.Second,
    }
    request, err := http.NewRequest(method, url, body)
    if err != nil {
        panic(err)
    }
    for k, v := range headers {
        request.Header.Set(k, v)
    }
    response, err := client.Do(request)
    if err != nil {
        panic(err)
    }
    defer response.Body.Close()

    bodyBytes, err := ioutil.ReadAll(response.Body)
    if err != nil {
        panic(err)
    }
    fmt.Println(string(bodyBytes))
}
using System.IO;
using System.Text;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System;


public class CsharpTest
{
    public static String HMACSHA1Text(String EncryptText, String EncryptKey)
    {
            HMACSHA1 hmacsha1 = new HMACSHA1();
            hmacsha1.Key = System.Text.Encoding.UTF8.GetBytes(EncryptKey);

            byte[] dataBuffer = System.Text.Encoding.UTF8.GetBytes(EncryptText);
            byte[] hashBytes = hmacsha1.ComputeHash(dataBuffer);
            return Convert.ToBase64String(hashBytes);
    }

    public static void Main(String[] args)
    {
        String url = "https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/search";
        String method = "GET";
        String querys = "keyword=%E5%A5%A5%E8%BF%AA";
        String source = "market";

        //云市场分配的密钥Id
        String  secretId = "xxx";
        //云市场分配的密钥Key
        String  secretKey = "xxx";

        String dt = DateTime.UtcNow.GetDateTimeFormats('r')[0];
        url = url + "?" + querys;

        String signStr = "x-date: " + dt + "\n" + "x-source: " + source;
        String sign = HMACSHA1Text(signStr, secretKey);

        String auth = "hmac id=\"" + secretId + "\", algorithm=\"hmac-sha1\", headers=\"x-date x-source\", signature=\"";
        auth = auth + sign + "\"";
        Console.WriteLine(auth + "\n");

        HttpWebRequest httpRequest = null;
        HttpWebResponse httpResponse = null;

        if (url.Contains("https://"))
        {
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
            httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
        }
        else
        {
            httpRequest = (HttpWebRequest)WebRequest.Create(url);
        }

        httpRequest.Method = method;
        httpRequest.Headers.Add("Authorization", auth);
        httpRequest.Headers.Add("X-Source", source);
        httpRequest.Headers.Add("X-Date", dt);

        try
        {
            httpResponse = (HttpWebResponse)httpRequest.GetResponse();
        }
        catch (WebException ex)
        {
            httpResponse = (HttpWebResponse)ex.Response;
        }

        Console.WriteLine(httpResponse.StatusCode);
        Console.WriteLine(httpResponse.Headers);
        Stream st = httpResponse.GetResponseStream();
        StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
        Console.WriteLine(reader.ReadToEnd());
        Console.WriteLine("\n");

    }

    public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
    {
        return true;
    }
}
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

import sun.misc.BASE64Encoder;


class Demo {
    public static String calcAuthorization(String source, String secretId, String secretKey, String datetime)
            throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
        String signStr = "x-date: " + datetime + "\n" + "x-source: " + source;
        Mac mac = Mac.getInstance("HmacSHA1");
        Key sKey = new SecretKeySpec(secretKey.getBytes("UTF-8"), mac.getAlgorithm());
        mac.init(sKey);
        byte[] hash = mac.doFinal(signStr.getBytes("UTF-8"));
        String sig = new BASE64Encoder().encode(hash);

        String auth = "hmac id=\"" + secretId + "\", algorithm=\"hmac-sha1\", headers=\"x-date x-source\", signature=\"" + sig + "\"";
        return auth;
    }

    public static String urlencode(Map<?, ?> map) throws UnsupportedEncodingException {
        StringBuilder sb = new StringBuilder();
        for (Map.Entry<?, ?> entry : map.entrySet()) {
            if (sb.length() > 0) {
                sb.append("&");
            }
            sb.append(String.format("%s=%s",
                    URLEncoder.encode(entry.getKey().toString(), "UTF-8"),
                    URLEncoder.encode(entry.getValue().toString(), "UTF-8")
            ));
        }
        return sb.toString();
    }

    public static void main(String[] args) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
        //云市场分配的密钥Id
        String secretId = "xxxx";
        //云市场分配的密钥Key
        String secretKey = "xxxx";
        String source = "market";

        Calendar cd = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
        String datetime = sdf.format(cd.getTime());
        // 签名
        String auth = calcAuthorization(source, secretId, secretKey, datetime);
        // 请求方法
        String method = "GET";
        // 请求头
        Map<String, String> headers = new HashMap<String, String>();
        headers.put("X-Source", source);
        headers.put("X-Date", datetime);
        headers.put("Authorization", auth);

        // 查询参数
        Map<String, String> queryParams = new HashMap<String, String>();
        queryParams.put("keyword", "奥迪");
        // body参数
        Map<String, String> bodyParams = new HashMap<String, String>();

        // url参数拼接
        String url = "https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/search";
        if (!queryParams.isEmpty()) {
            url += "?" + urlencode(queryParams);
        }

        BufferedReader in = null;
        try {
            URL realUrl = new URL(url);
            HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
            conn.setConnectTimeout(5000);
            conn.setReadTimeout(5000);
            conn.setRequestMethod(method);

            // request headers
            for (Map.Entry<String, String> entry : headers.entrySet()) {
                conn.setRequestProperty(entry.getKey(), entry.getValue());
            }

            // request body
            Map<String, Boolean> methods = new HashMap<>();
            methods.put("POST", true);
            methods.put("PUT", true);
            methods.put("PATCH", true);
            Boolean hasBody = methods.get(method);
            if (hasBody != null) {
                conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

                conn.setDoOutput(true);
                DataOutputStream out = new DataOutputStream(conn.getOutputStream());
                out.writeBytes(urlencode(bodyParams));
                out.flush();
                out.close();
            }

            // 定义 BufferedReader输入流来读取URL的响应
            in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String line;
            String result = "";
            while ((line = in.readLine()) != null) {
                result += line;
            }

            System.out.println(result);
        } catch (Exception e) {
            System.out.println(e);
            e.printStackTrace();
        } finally {
            try {
                if (in != null) {
                    in.close();
                }
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }
    }
}

正常返回示例

                                                                    {
    "status": 0,
    "msg": "ok",
    "result": {
        "keyword": "奔驰E级2017款E200运动版",
        "list": [
            {
                "id": "34420",
                "name": "2017款 E 200 运动轿车",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/34420.jpg",
                "price": "",
                "yeartype": "2017",
                "productionstate": "在产",
                "salestate": "在销",
                "sizetype": "中大型车"
            },
            {
                "id": "34422",
                "name": "2017款 E 200 运动轿车 4MATIC",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/34422.jpg",
                "price": "",
                "yeartype": "2017",
                "productionstate": "在产",
                "salestate": "在销",
                "sizetype": "中大型车"
            },
            {
                "id": "34424",
                "name": "2017款 E 200 L 运动轿车 4MATIC ",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/34424.jpg",
                "price": "",
                "yeartype": "2017",
                "productionstate": "在产",
                "salestate": "在销",
                "sizetype": "中大型车"
            }
        ]
    }
}
                                                                

失败返回示例

                                                                    {
    "status": "205",
    "msg": "没有信息",
    "result": ""
}
                                                                

返回码定义

返回码
返回信息
描述
205
没有信息

根据车型获取车

调用地址:https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/car

请求方式:GET

返回类型:HTML

API调用: API调用说明(secret_id & secret_key)

请求参数(Headers)

名称
类型
是否必须
描述
暂无数据

请求参数(Query)

名称
类型
是否必须
描述
parentid
string
上级ID

请求参数(Body)

名称
类型
是否必须
描述
暂无数据

请求示例

# -*- coding: utf-8 -*-
from __future__ import print_function

import ssl, hmac, base64, hashlib
from datetime import datetime as pydatetime

try:
    from urllib import urlencode
    from urllib2 import Request, urlopen
except ImportError:
    from urllib.parse import urlencode
    from urllib.request import Request, urlopen

# 云市场分配的密钥Id
secretId = "xxxx"
# 云市场分配的密钥Key
secretKey = "xxxx"
source = "market"

# 签名
datetime = pydatetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT')
signStr = "x-date: %s\nx-source: %s" % (datetime, source)
sign = base64.b64encode(hmac.new(secretKey.encode('utf-8'), signStr.encode('utf-8'), hashlib.sha1).digest())
auth = 'hmac id="%s", algorithm="hmac-sha1", headers="x-date x-source", signature="%s"' % (secretId, sign.decode('utf-8'))

# 请求方法
method = 'GET'
# 请求头
headers = {
    'X-Source': source,
    'X-Date': datetime,
    'Authorization': auth,
}
# 查询参数
queryParams = {
    'parentid': '220'}
# body参数(POST方法下存在)
bodyParams = {
}
# url参数拼接
url = 'https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/car'
if len(queryParams.keys()) > 0:
    url = url + '?' + urlencode(queryParams)

request = Request(url, headers=headers)
request.get_method = lambda: method
if method in ('POST', 'PUT', 'PATCH'):
    request.data = urlencode(bodyParams).encode('utf-8')
    request.add_header('Content-Type', 'application/x-www-form-urlencoded')
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
response = urlopen(request, context=ctx)
content = response.read()
if content:
    print(content.decode('utf-8'))
curl -v -X GET https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/car ?parentid=220-H 'Host:service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com' -H 'Source:source' -H 'Date:Mon, 19 Mar 2018 12:08:40 GMT' -H 'Authorization:hmac id = "AKIDi6qE41WgJ9w8h4h9zq68Vq24d1beIuN0qIwU", algorithm = "hmac-sha1", headers = "date source", signature = yMCxXNytW5nvVGNZ8aBtRxmiLJ4=' -H 'X-Requested-With:XMLHttpRequest' 
//请用云市场分配给您的密钥计算签名并放入请求头,Date为当前的GMT时间
<?php
// 云市场分配的密钥Id
$secretId = 'xxxx';
// 云市场分配的密钥Key
$secretKey = 'xxxx';
$source = 'market';

// 签名
$datetime = gmdate('D, d M Y H:i:s T');
$signStr = sprintf("x-date: %s\nx-source: %s", $datetime, $source);
$sign = base64_encode(hash_hmac('sha1', $signStr, $secretKey, true));
$auth = sprintf('hmac id="%s", algorithm="hmac-sha1", headers="x-date x-source", signature="%s"', $secretId, $sign);

// 请求方法
$method = 'GET';
// 请求头
$headers = array(
    'X-Source' => $source,
    'X-Date' => $datetime,
    'Authorization' => $auth,
);
// 查询参数
$queryParams = array (
    'parentid' => '220',
);
// body参数(POST方法下)
$bodyParams = array (
);
// url参数拼接
$url = 'https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/car';
if (count($queryParams) > 0) {
    $url .= '?' . http_build_query($queryParams);
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_HTTPHEADER, array_map(function ($v, $k) {
    return $k . ': ' . $v;
}, array_values($headers), array_keys($headers)));
if (in_array($method, array('POST', 'PUT', 'PATCH'), true)) {
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($bodyParams));
}

$data = curl_exec($ch);
if (curl_errno($ch)) {
    echo "Error: " . curl_error($ch);
} else {
    print_r($data);
}
curl_close($ch);
/**
 * npm install crypto-js request
 */
var CryptoJS = require("crypto-js");
var request = require('request');
var querystring = require('querystring');

// 云市场分配的密钥Id
var secretId = "xxx";
// 云市场分配的密钥Key
var secretKey = "xxx";
var source = "market";

// 签名
var datetime = (new Date()).toGMTString();
var signStr = "x-date: " + datetime + "\n" + "x-source: " + source;
var sign = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA1(signStr, secretKey))
var auth = 'hmac id="' + secretId + '", algorithm="hmac-sha1", headers="x-date x-source", signature="' + sign + '"';

// 请求方法
var method = 'GET';
// 请求头
var headers = {
    "X-Source": source,
    "X-Date": datetime,
    "Authorization": auth,
}
// 查询参数
var queryParams = {
    'parentid': '220'}
// body参数(POST方法下)
var bodyParams = {
}
// url参数拼接
var url = 'https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/car';
if (Object.keys(queryParams).length > 0) {
    url += '?' + querystring.stringify(queryParams);
}

var options = {
    url: url,
    timeout: 5000,
    method: method,
    headers: headers
}
if (['POST', 'PUT', 'PATCH'].indexOf(method) != -1) {
    options['body'] = querystring.stringify(bodyParams);
    options['headers']['Content-Type'] = "application/x-www-form-urlencoded";
}

request(options, function (error, response, body) {
    if (error !== null) {
        console.log('error:', error);
        return;
    }
    console.log(body);
});
package main

import (
    "crypto/hmac"
    "crypto/sha1"
    "encoding/base64"
    "fmt"
    "io"
    "io/ioutil"
    "net/http"
    gourl "net/url"
    "strings"
    "time"
)

func calcAuthorization(source string, secretId string, secretKey string) (auth string, datetime string, err error) {
    timeLocation, _ := time.LoadLocation("Etc/GMT")
    datetime = time.Now().In(timeLocation).Format("Mon, 02 Jan 2006 15:04:05 GMT")
    signStr := fmt.Sprintf("x-date: %s\nx-source: %s", datetime, source)

    // hmac-sha1
    mac := hmac.New(sha1.New, []byte(secretKey))
    mac.Write([]byte(signStr))
    sign := base64.StdEncoding.EncodeToString(mac.Sum(nil))

    auth = fmt.Sprintf("hmac id=\"%s\", algorithm=\"hmac-sha1\", headers=\"x-date x-source\", signature=\"%s\"",
        secretId, sign)

    return auth, datetime, nil
}

func urlencode(params map[string]string) string {
    var p = gourl.Values{}
    for k, v := range params {
        p.Add(k, v)
    }
    return p.Encode()
}

func main() {
    // 云市场分配的密钥Id
    secretId := "xxxx"
    // 云市场分配的密钥Key
    secretKey := "xxxx"
    source := "market"

    // 签名
    auth, datetime, _ := calcAuthorization(source, secretId, secretKey)

    // 请求方法
    method := "GET"
    // 请求头
    headers := map[string]string{"X-Source": source, "X-Date": datetime, "Authorization": auth}

    // 查询参数
    queryParams := make(map[string]string)
    queryParams["parentid"] = "220"
    // body参数
    bodyParams := make(map[string]string)

    // url参数拼接
    url := "https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/car"
    if len(queryParams) > 0 {
        url = fmt.Sprintf("%s?%s", url, urlencode(queryParams))
    }

    bodyMethods := map[string]bool{"POST": true, "PUT": true, "PATCH": true}
    var body io.Reader = nil
    if bodyMethods[method] {
        body = strings.NewReader(urlencode(bodyParams))
        headers["Content-Type"] = "application/x-www-form-urlencoded"
    }

    client := &http.Client{
        Timeout: 5 * time.Second,
    }
    request, err := http.NewRequest(method, url, body)
    if err != nil {
        panic(err)
    }
    for k, v := range headers {
        request.Header.Set(k, v)
    }
    response, err := client.Do(request)
    if err != nil {
        panic(err)
    }
    defer response.Body.Close()

    bodyBytes, err := ioutil.ReadAll(response.Body)
    if err != nil {
        panic(err)
    }
    fmt.Println(string(bodyBytes))
}
using System.IO;
using System.Text;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System;


public class CsharpTest
{
    public static String HMACSHA1Text(String EncryptText, String EncryptKey)
    {
            HMACSHA1 hmacsha1 = new HMACSHA1();
            hmacsha1.Key = System.Text.Encoding.UTF8.GetBytes(EncryptKey);

            byte[] dataBuffer = System.Text.Encoding.UTF8.GetBytes(EncryptText);
            byte[] hashBytes = hmacsha1.ComputeHash(dataBuffer);
            return Convert.ToBase64String(hashBytes);
    }

    public static void Main(String[] args)
    {
        String url = "https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/car";
        String method = "GET";
        String querys = "parentid=220";
        String source = "market";

        //云市场分配的密钥Id
        String  secretId = "xxx";
        //云市场分配的密钥Key
        String  secretKey = "xxx";

        String dt = DateTime.UtcNow.GetDateTimeFormats('r')[0];
        url = url + "?" + querys;

        String signStr = "x-date: " + dt + "\n" + "x-source: " + source;
        String sign = HMACSHA1Text(signStr, secretKey);

        String auth = "hmac id=\"" + secretId + "\", algorithm=\"hmac-sha1\", headers=\"x-date x-source\", signature=\"";
        auth = auth + sign + "\"";
        Console.WriteLine(auth + "\n");

        HttpWebRequest httpRequest = null;
        HttpWebResponse httpResponse = null;

        if (url.Contains("https://"))
        {
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
            httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
        }
        else
        {
            httpRequest = (HttpWebRequest)WebRequest.Create(url);
        }

        httpRequest.Method = method;
        httpRequest.Headers.Add("Authorization", auth);
        httpRequest.Headers.Add("X-Source", source);
        httpRequest.Headers.Add("X-Date", dt);

        try
        {
            httpResponse = (HttpWebResponse)httpRequest.GetResponse();
        }
        catch (WebException ex)
        {
            httpResponse = (HttpWebResponse)ex.Response;
        }

        Console.WriteLine(httpResponse.StatusCode);
        Console.WriteLine(httpResponse.Headers);
        Stream st = httpResponse.GetResponseStream();
        StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
        Console.WriteLine(reader.ReadToEnd());
        Console.WriteLine("\n");

    }

    public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
    {
        return true;
    }
}
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

import sun.misc.BASE64Encoder;


class Demo {
    public static String calcAuthorization(String source, String secretId, String secretKey, String datetime)
            throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
        String signStr = "x-date: " + datetime + "\n" + "x-source: " + source;
        Mac mac = Mac.getInstance("HmacSHA1");
        Key sKey = new SecretKeySpec(secretKey.getBytes("UTF-8"), mac.getAlgorithm());
        mac.init(sKey);
        byte[] hash = mac.doFinal(signStr.getBytes("UTF-8"));
        String sig = new BASE64Encoder().encode(hash);

        String auth = "hmac id=\"" + secretId + "\", algorithm=\"hmac-sha1\", headers=\"x-date x-source\", signature=\"" + sig + "\"";
        return auth;
    }

    public static String urlencode(Map<?, ?> map) throws UnsupportedEncodingException {
        StringBuilder sb = new StringBuilder();
        for (Map.Entry<?, ?> entry : map.entrySet()) {
            if (sb.length() > 0) {
                sb.append("&");
            }
            sb.append(String.format("%s=%s",
                    URLEncoder.encode(entry.getKey().toString(), "UTF-8"),
                    URLEncoder.encode(entry.getValue().toString(), "UTF-8")
            ));
        }
        return sb.toString();
    }

    public static void main(String[] args) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
        //云市场分配的密钥Id
        String secretId = "xxxx";
        //云市场分配的密钥Key
        String secretKey = "xxxx";
        String source = "market";

        Calendar cd = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
        String datetime = sdf.format(cd.getTime());
        // 签名
        String auth = calcAuthorization(source, secretId, secretKey, datetime);
        // 请求方法
        String method = "GET";
        // 请求头
        Map<String, String> headers = new HashMap<String, String>();
        headers.put("X-Source", source);
        headers.put("X-Date", datetime);
        headers.put("Authorization", auth);

        // 查询参数
        Map<String, String> queryParams = new HashMap<String, String>();
        queryParams.put("parentid", "220");
        // body参数
        Map<String, String> bodyParams = new HashMap<String, String>();

        // url参数拼接
        String url = "https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/car";
        if (!queryParams.isEmpty()) {
            url += "?" + urlencode(queryParams);
        }

        BufferedReader in = null;
        try {
            URL realUrl = new URL(url);
            HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
            conn.setConnectTimeout(5000);
            conn.setReadTimeout(5000);
            conn.setRequestMethod(method);

            // request headers
            for (Map.Entry<String, String> entry : headers.entrySet()) {
                conn.setRequestProperty(entry.getKey(), entry.getValue());
            }

            // request body
            Map<String, Boolean> methods = new HashMap<>();
            methods.put("POST", true);
            methods.put("PUT", true);
            methods.put("PATCH", true);
            Boolean hasBody = methods.get(method);
            if (hasBody != null) {
                conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

                conn.setDoOutput(true);
                DataOutputStream out = new DataOutputStream(conn.getOutputStream());
                out.writeBytes(urlencode(bodyParams));
                out.flush();
                out.close();
            }

            // 定义 BufferedReader输入流来读取URL的响应
            in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String line;
            String result = "";
            while ((line = in.readLine()) != null) {
                result += line;
            }

            System.out.println(result);
        } catch (Exception e) {
            System.out.println(e);
            e.printStackTrace();
        } finally {
            try {
                if (in != null) {
                    in.close();
                }
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }
    }
}

正常返回示例

                                                                    {
    "status": 0,
    "msg": "ok",
    "result": {
        "id": "220",
        "name": "A3",
        "initial": "A",
        "fullname": "奥迪A3",
        "logo": "http://api.jisuapi.com/car/static/images/logo/300/220.jpg",
        "salestate": "在销",
        "depth": "3",
        "list": [
            {
                "id": "2571",
                "name": "2016款 Sportback 35TFSI 进取型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2571.jpg",
                "price": "18.49万",
                "yeartype": "2016",
                "productionstate": "在产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2572",
                "name": "2016款 Limousine 35TFSI 进取型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2572.jpg",
                "price": "19.09万",
                "yeartype": "2016",
                "productionstate": "在产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2573",
                "name": "2016款 Sportback 35TFSI 领英型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2573.jpg",
                "price": "20.92万",
                "yeartype": "2016",
                "productionstate": "在产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2574",
                "name": "2016款 Limousine 35TFSI 领英型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2574.jpg",
                "price": "21.52万",
                "yeartype": "2016",
                "productionstate": "在产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2575",
                "name": "2016款 Sportback 35TFSI 风尚型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2575.jpg",
                "price": "22.59万",
                "yeartype": "2016",
                "productionstate": "在产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2576",
                "name": "2016款 Limousine 35TFSI 风尚型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2576.jpg",
                "price": "23.19万",
                "yeartype": "2016",
                "productionstate": "在产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2577",
                "name": "2015款 Sportback 35TFSI 手动 进取型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2577.jpg",
                "price": "18.49万",
                "yeartype": "2015",
                "productionstate": "停产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2578",
                "name": "2015款 Limousine 35TFSI 手动 进取型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2578.jpg",
                "price": "19.09万",
                "yeartype": "2015",
                "productionstate": "停产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2579",
                "name": "2015款 Sportback 35 TFSI 纪念智领版",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2579.jpg",
                "price": "22.79万",
                "yeartype": "2015",
                "productionstate": "停产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2580",
                "name": "2015款 Limousine 35 TFSI 纪念智领版",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2580.jpg",
                "price": "23.39万",
                "yeartype": "2015",
                "productionstate": "停产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2581",
                "name": "2015款 Sportback 35 TFSI 纪念舒享版",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2581.jpg",
                "price": "23.98万",
                "yeartype": "2015",
                "productionstate": "停产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2582",
                "name": "2015款 Limousine 35 TFSI 纪念舒享版",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2582.jpg",
                "price": "24.58万",
                "yeartype": "2015",
                "productionstate": "停产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2583",
                "name": "2015款 Sportback 35 TFSI 纪念乐享版",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2583.jpg",
                "price": "27.57万",
                "yeartype": "2015",
                "productionstate": "停产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2584",
                "name": "2015款 Limousine 35 TFSI 纪念乐享版",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2584.jpg",
                "price": "28.17万",
                "yeartype": "2015",
                "productionstate": "停产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2585",
                "name": "2014款 Sportback 35TFSI 进取型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2585.jpg",
                "price": "19.99万",
                "yeartype": "2014",
                "productionstate": "停产",
                "salestate": "停产",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2586",
                "name": "2014款 Limousine 35TFSI 进取型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2586.jpg",
                "price": "20.59万",
                "yeartype": "2014",
                "productionstate": "停产",
                "salestate": "停产",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2587",
                "name": "2014款 Sportback 35TFSI 时尚型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2587.jpg",
                "price": "21.89万",
                "yeartype": "2014",
                "productionstate": "停产",
                "salestate": "停产",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2588",
                "name": "2014款 Limousine 35TFSI 时尚型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2588.jpg",
                "price": "22.49万",
                "yeartype": "2014",
                "productionstate": "停产",
                "salestate": "停产",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2589",
                "name": "2014款 Sportback 35TFSI 舒适型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2589.jpg",
                "price": "24.88万",
                "yeartype": "2014",
                "productionstate": "停产",
                "salestate": "停产",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2590",
                "name": "2014款 Limousine 35TFSI 舒适型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2590.jpg",
                "price": "25.48万",
                "yeartype": "2014",
                "productionstate": "停产",
                "salestate": "停产",
                "sizetype": "紧凑型车"
            }
        ]
    }
}

                                                                

失败返回示例

                                                                    {
    "status": "201",
    "msg": "上级ID错误",
    "result": ""
}
                                                                

返回码定义

返回码
返回信息
描述
201
上级ID错误

根据品牌获取车型

调用地址:https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/type

请求方式:GET

返回类型:HTML

API调用: API调用说明(secret_id & secret_key)

请求参数(Headers)

名称
类型
是否必须
描述
暂无数据

请求参数(Query)

名称
类型
是否必须
描述
parentid
string
上级ID

请求参数(Body)

名称
类型
是否必须
描述
暂无数据

请求示例

# -*- coding: utf-8 -*-
from __future__ import print_function

import ssl, hmac, base64, hashlib
from datetime import datetime as pydatetime

try:
    from urllib import urlencode
    from urllib2 import Request, urlopen
except ImportError:
    from urllib.parse import urlencode
    from urllib.request import Request, urlopen

# 云市场分配的密钥Id
secretId = "xxxx"
# 云市场分配的密钥Key
secretKey = "xxxx"
source = "market"

# 签名
datetime = pydatetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT')
signStr = "x-date: %s\nx-source: %s" % (datetime, source)
sign = base64.b64encode(hmac.new(secretKey.encode('utf-8'), signStr.encode('utf-8'), hashlib.sha1).digest())
auth = 'hmac id="%s", algorithm="hmac-sha1", headers="x-date x-source", signature="%s"' % (secretId, sign.decode('utf-8'))

# 请求方法
method = 'GET'
# 请求头
headers = {
    'X-Source': source,
    'X-Date': datetime,
    'Authorization': auth,
}
# 查询参数
queryParams = {
    'parentid': ''}
# body参数(POST方法下存在)
bodyParams = {
}
# url参数拼接
url = 'https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/type'
if len(queryParams.keys()) > 0:
    url = url + '?' + urlencode(queryParams)

request = Request(url, headers=headers)
request.get_method = lambda: method
if method in ('POST', 'PUT', 'PATCH'):
    request.data = urlencode(bodyParams).encode('utf-8')
    request.add_header('Content-Type', 'application/x-www-form-urlencoded')
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
response = urlopen(request, context=ctx)
content = response.read()
if content:
    print(content.decode('utf-8'))
curl -v -X GET https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/type ?parentid=-H 'Host:service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com' -H 'Source:source' -H 'Date:Mon, 19 Mar 2018 12:08:40 GMT' -H 'Authorization:hmac id = "AKIDi6qE41WgJ9w8h4h9zq68Vq24d1beIuN0qIwU", algorithm = "hmac-sha1", headers = "date source", signature = yMCxXNytW5nvVGNZ8aBtRxmiLJ4=' -H 'X-Requested-With:XMLHttpRequest' 
//请用云市场分配给您的密钥计算签名并放入请求头,Date为当前的GMT时间
<?php
// 云市场分配的密钥Id
$secretId = 'xxxx';
// 云市场分配的密钥Key
$secretKey = 'xxxx';
$source = 'market';

// 签名
$datetime = gmdate('D, d M Y H:i:s T');
$signStr = sprintf("x-date: %s\nx-source: %s", $datetime, $source);
$sign = base64_encode(hash_hmac('sha1', $signStr, $secretKey, true));
$auth = sprintf('hmac id="%s", algorithm="hmac-sha1", headers="x-date x-source", signature="%s"', $secretId, $sign);

// 请求方法
$method = 'GET';
// 请求头
$headers = array(
    'X-Source' => $source,
    'X-Date' => $datetime,
    'Authorization' => $auth,
);
// 查询参数
$queryParams = array (
    'parentid' => '',
);
// body参数(POST方法下)
$bodyParams = array (
);
// url参数拼接
$url = 'https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/type';
if (count($queryParams) > 0) {
    $url .= '?' . http_build_query($queryParams);
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_HTTPHEADER, array_map(function ($v, $k) {
    return $k . ': ' . $v;
}, array_values($headers), array_keys($headers)));
if (in_array($method, array('POST', 'PUT', 'PATCH'), true)) {
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($bodyParams));
}

$data = curl_exec($ch);
if (curl_errno($ch)) {
    echo "Error: " . curl_error($ch);
} else {
    print_r($data);
}
curl_close($ch);
/**
 * npm install crypto-js request
 */
var CryptoJS = require("crypto-js");
var request = require('request');
var querystring = require('querystring');

// 云市场分配的密钥Id
var secretId = "xxx";
// 云市场分配的密钥Key
var secretKey = "xxx";
var source = "market";

// 签名
var datetime = (new Date()).toGMTString();
var signStr = "x-date: " + datetime + "\n" + "x-source: " + source;
var sign = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA1(signStr, secretKey))
var auth = 'hmac id="' + secretId + '", algorithm="hmac-sha1", headers="x-date x-source", signature="' + sign + '"';

// 请求方法
var method = 'GET';
// 请求头
var headers = {
    "X-Source": source,
    "X-Date": datetime,
    "Authorization": auth,
}
// 查询参数
var queryParams = {
    'parentid': ''}
// body参数(POST方法下)
var bodyParams = {
}
// url参数拼接
var url = 'https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/type';
if (Object.keys(queryParams).length > 0) {
    url += '?' + querystring.stringify(queryParams);
}

var options = {
    url: url,
    timeout: 5000,
    method: method,
    headers: headers
}
if (['POST', 'PUT', 'PATCH'].indexOf(method) != -1) {
    options['body'] = querystring.stringify(bodyParams);
    options['headers']['Content-Type'] = "application/x-www-form-urlencoded";
}

request(options, function (error, response, body) {
    if (error !== null) {
        console.log('error:', error);
        return;
    }
    console.log(body);
});
package main

import (
    "crypto/hmac"
    "crypto/sha1"
    "encoding/base64"
    "fmt"
    "io"
    "io/ioutil"
    "net/http"
    gourl "net/url"
    "strings"
    "time"
)

func calcAuthorization(source string, secretId string, secretKey string) (auth string, datetime string, err error) {
    timeLocation, _ := time.LoadLocation("Etc/GMT")
    datetime = time.Now().In(timeLocation).Format("Mon, 02 Jan 2006 15:04:05 GMT")
    signStr := fmt.Sprintf("x-date: %s\nx-source: %s", datetime, source)

    // hmac-sha1
    mac := hmac.New(sha1.New, []byte(secretKey))
    mac.Write([]byte(signStr))
    sign := base64.StdEncoding.EncodeToString(mac.Sum(nil))

    auth = fmt.Sprintf("hmac id=\"%s\", algorithm=\"hmac-sha1\", headers=\"x-date x-source\", signature=\"%s\"",
        secretId, sign)

    return auth, datetime, nil
}

func urlencode(params map[string]string) string {
    var p = gourl.Values{}
    for k, v := range params {
        p.Add(k, v)
    }
    return p.Encode()
}

func main() {
    // 云市场分配的密钥Id
    secretId := "xxxx"
    // 云市场分配的密钥Key
    secretKey := "xxxx"
    source := "market"

    // 签名
    auth, datetime, _ := calcAuthorization(source, secretId, secretKey)

    // 请求方法
    method := "GET"
    // 请求头
    headers := map[string]string{"X-Source": source, "X-Date": datetime, "Authorization": auth}

    // 查询参数
    queryParams := make(map[string]string)
    queryParams["parentid"] = ""
    // body参数
    bodyParams := make(map[string]string)

    // url参数拼接
    url := "https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/type"
    if len(queryParams) > 0 {
        url = fmt.Sprintf("%s?%s", url, urlencode(queryParams))
    }

    bodyMethods := map[string]bool{"POST": true, "PUT": true, "PATCH": true}
    var body io.Reader = nil
    if bodyMethods[method] {
        body = strings.NewReader(urlencode(bodyParams))
        headers["Content-Type"] = "application/x-www-form-urlencoded"
    }

    client := &http.Client{
        Timeout: 5 * time.Second,
    }
    request, err := http.NewRequest(method, url, body)
    if err != nil {
        panic(err)
    }
    for k, v := range headers {
        request.Header.Set(k, v)
    }
    response, err := client.Do(request)
    if err != nil {
        panic(err)
    }
    defer response.Body.Close()

    bodyBytes, err := ioutil.ReadAll(response.Body)
    if err != nil {
        panic(err)
    }
    fmt.Println(string(bodyBytes))
}
using System.IO;
using System.Text;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System;


public class CsharpTest
{
    public static String HMACSHA1Text(String EncryptText, String EncryptKey)
    {
            HMACSHA1 hmacsha1 = new HMACSHA1();
            hmacsha1.Key = System.Text.Encoding.UTF8.GetBytes(EncryptKey);

            byte[] dataBuffer = System.Text.Encoding.UTF8.GetBytes(EncryptText);
            byte[] hashBytes = hmacsha1.ComputeHash(dataBuffer);
            return Convert.ToBase64String(hashBytes);
    }

    public static void Main(String[] args)
    {
        String url = "https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/type";
        String method = "GET";
        String querys = "parentid=";
        String source = "market";

        //云市场分配的密钥Id
        String  secretId = "xxx";
        //云市场分配的密钥Key
        String  secretKey = "xxx";

        String dt = DateTime.UtcNow.GetDateTimeFormats('r')[0];
        url = url + "?" + querys;

        String signStr = "x-date: " + dt + "\n" + "x-source: " + source;
        String sign = HMACSHA1Text(signStr, secretKey);

        String auth = "hmac id=\"" + secretId + "\", algorithm=\"hmac-sha1\", headers=\"x-date x-source\", signature=\"";
        auth = auth + sign + "\"";
        Console.WriteLine(auth + "\n");

        HttpWebRequest httpRequest = null;
        HttpWebResponse httpResponse = null;

        if (url.Contains("https://"))
        {
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
            httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
        }
        else
        {
            httpRequest = (HttpWebRequest)WebRequest.Create(url);
        }

        httpRequest.Method = method;
        httpRequest.Headers.Add("Authorization", auth);
        httpRequest.Headers.Add("X-Source", source);
        httpRequest.Headers.Add("X-Date", dt);

        try
        {
            httpResponse = (HttpWebResponse)httpRequest.GetResponse();
        }
        catch (WebException ex)
        {
            httpResponse = (HttpWebResponse)ex.Response;
        }

        Console.WriteLine(httpResponse.StatusCode);
        Console.WriteLine(httpResponse.Headers);
        Stream st = httpResponse.GetResponseStream();
        StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
        Console.WriteLine(reader.ReadToEnd());
        Console.WriteLine("\n");

    }

    public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
    {
        return true;
    }
}
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

import sun.misc.BASE64Encoder;


class Demo {
    public static String calcAuthorization(String source, String secretId, String secretKey, String datetime)
            throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
        String signStr = "x-date: " + datetime + "\n" + "x-source: " + source;
        Mac mac = Mac.getInstance("HmacSHA1");
        Key sKey = new SecretKeySpec(secretKey.getBytes("UTF-8"), mac.getAlgorithm());
        mac.init(sKey);
        byte[] hash = mac.doFinal(signStr.getBytes("UTF-8"));
        String sig = new BASE64Encoder().encode(hash);

        String auth = "hmac id=\"" + secretId + "\", algorithm=\"hmac-sha1\", headers=\"x-date x-source\", signature=\"" + sig + "\"";
        return auth;
    }

    public static String urlencode(Map<?, ?> map) throws UnsupportedEncodingException {
        StringBuilder sb = new StringBuilder();
        for (Map.Entry<?, ?> entry : map.entrySet()) {
            if (sb.length() > 0) {
                sb.append("&");
            }
            sb.append(String.format("%s=%s",
                    URLEncoder.encode(entry.getKey().toString(), "UTF-8"),
                    URLEncoder.encode(entry.getValue().toString(), "UTF-8")
            ));
        }
        return sb.toString();
    }

    public static void main(String[] args) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
        //云市场分配的密钥Id
        String secretId = "xxxx";
        //云市场分配的密钥Key
        String secretKey = "xxxx";
        String source = "market";

        Calendar cd = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
        String datetime = sdf.format(cd.getTime());
        // 签名
        String auth = calcAuthorization(source, secretId, secretKey, datetime);
        // 请求方法
        String method = "GET";
        // 请求头
        Map<String, String> headers = new HashMap<String, String>();
        headers.put("X-Source", source);
        headers.put("X-Date", datetime);
        headers.put("Authorization", auth);

        // 查询参数
        Map<String, String> queryParams = new HashMap<String, String>();
        queryParams.put("parentid", "");
        // body参数
        Map<String, String> bodyParams = new HashMap<String, String>();

        // url参数拼接
        String url = "https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/type";
        if (!queryParams.isEmpty()) {
            url += "?" + urlencode(queryParams);
        }

        BufferedReader in = null;
        try {
            URL realUrl = new URL(url);
            HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
            conn.setConnectTimeout(5000);
            conn.setReadTimeout(5000);
            conn.setRequestMethod(method);

            // request headers
            for (Map.Entry<String, String> entry : headers.entrySet()) {
                conn.setRequestProperty(entry.getKey(), entry.getValue());
            }

            // request body
            Map<String, Boolean> methods = new HashMap<>();
            methods.put("POST", true);
            methods.put("PUT", true);
            methods.put("PATCH", true);
            Boolean hasBody = methods.get(method);
            if (hasBody != null) {
                conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

                conn.setDoOutput(true);
                DataOutputStream out = new DataOutputStream(conn.getOutputStream());
                out.writeBytes(urlencode(bodyParams));
                out.flush();
                out.close();
            }

            // 定义 BufferedReader输入流来读取URL的响应
            in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String line;
            String result = "";
            while ((line = in.readLine()) != null) {
                result += line;
            }

            System.out.println(result);
        } catch (Exception e) {
            System.out.println(e);
            e.printStackTrace();
        } finally {
            try {
                if (in != null) {
                    in.close();
                }
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }
    }
}

正常返回示例

                                                                    {
    "status": 0,
    "msg": "ok",
    "result": {
        "id": "220",
        "name": "A3",
        "initial": "A",
        "fullname": "奥迪A3",
        "logo": "http://api.jisuapi.com/car/static/images/logo/300/220.jpg",
        "salestate": "在销",
        "depth": "3",
        "list": [
            {
                "id": "2571",
                "name": "2016款 Sportback 35TFSI 进取型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2571.jpg",
                "price": "18.49万",
                "yeartype": "2016",
                "productionstate": "在产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2572",
                "name": "2016款 Limousine 35TFSI 进取型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2572.jpg",
                "price": "19.09万",
                "yeartype": "2016",
                "productionstate": "在产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2573",
                "name": "2016款 Sportback 35TFSI 领英型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2573.jpg",
                "price": "20.92万",
                "yeartype": "2016",
                "productionstate": "在产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2574",
                "name": "2016款 Limousine 35TFSI 领英型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2574.jpg",
                "price": "21.52万",
                "yeartype": "2016",
                "productionstate": "在产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2575",
                "name": "2016款 Sportback 35TFSI 风尚型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2575.jpg",
                "price": "22.59万",
                "yeartype": "2016",
                "productionstate": "在产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2576",
                "name": "2016款 Limousine 35TFSI 风尚型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2576.jpg",
                "price": "23.19万",
                "yeartype": "2016",
                "productionstate": "在产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2577",
                "name": "2015款 Sportback 35TFSI 手动 进取型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2577.jpg",
                "price": "18.49万",
                "yeartype": "2015",
                "productionstate": "停产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2578",
                "name": "2015款 Limousine 35TFSI 手动 进取型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2578.jpg",
                "price": "19.09万",
                "yeartype": "2015",
                "productionstate": "停产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2579",
                "name": "2015款 Sportback 35 TFSI 纪念智领版",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2579.jpg",
                "price": "22.79万",
                "yeartype": "2015",
                "productionstate": "停产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2580",
                "name": "2015款 Limousine 35 TFSI 纪念智领版",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2580.jpg",
                "price": "23.39万",
                "yeartype": "2015",
                "productionstate": "停产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2581",
                "name": "2015款 Sportback 35 TFSI 纪念舒享版",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2581.jpg",
                "price": "23.98万",
                "yeartype": "2015",
                "productionstate": "停产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2582",
                "name": "2015款 Limousine 35 TFSI 纪念舒享版",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2582.jpg",
                "price": "24.58万",
                "yeartype": "2015",
                "productionstate": "停产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2583",
                "name": "2015款 Sportback 35 TFSI 纪念乐享版",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2583.jpg",
                "price": "27.57万",
                "yeartype": "2015",
                "productionstate": "停产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2584",
                "name": "2015款 Limousine 35 TFSI 纪念乐享版",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2584.jpg",
                "price": "28.17万",
                "yeartype": "2015",
                "productionstate": "停产",
                "salestate": "在销",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2585",
                "name": "2014款 Sportback 35TFSI 进取型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2585.jpg",
                "price": "19.99万",
                "yeartype": "2014",
                "productionstate": "停产",
                "salestate": "停产",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2586",
                "name": "2014款 Limousine 35TFSI 进取型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2586.jpg",
                "price": "20.59万",
                "yeartype": "2014",
                "productionstate": "停产",
                "salestate": "停产",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2587",
                "name": "2014款 Sportback 35TFSI 时尚型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2587.jpg",
                "price": "21.89万",
                "yeartype": "2014",
                "productionstate": "停产",
                "salestate": "停产",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2588",
                "name": "2014款 Limousine 35TFSI 时尚型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2588.jpg",
                "price": "22.49万",
                "yeartype": "2014",
                "productionstate": "停产",
                "salestate": "停产",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2589",
                "name": "2014款 Sportback 35TFSI 舒适型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2589.jpg",
                "price": "24.88万",
                "yeartype": "2014",
                "productionstate": "停产",
                "salestate": "停产",
                "sizetype": "紧凑型车"
            },
            {
                "id": "2590",
                "name": "2014款 Limousine 35TFSI 舒适型",
                "logo": "http://api.jisuapi.com/car/static/images/logo/300/2590.jpg",
                "price": "25.48万",
                "yeartype": "2014",
                "productionstate": "停产",
                "salestate": "停产",
                "sizetype": "紧凑型车"
            }
        ]
    }
}
                                                                

失败返回示例

                                                                    {
    "status": "201",
    "msg": "上级ID错误",
    "result": ""
}
                                                                

返回码定义

返回码
返回信息
描述
201
上级ID错误

根据ID获取车型详情

调用地址:https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/detail

请求方式:GET

返回类型:HTML

API调用: API调用说明(secret_id & secret_key)

请求参数(Headers)

名称
类型
是否必须
描述
暂无数据

请求参数(Query)

名称
类型
是否必须
描述
carid
int
车ID 对应其他API中的ID

请求参数(Body)

名称
类型
是否必须
描述
暂无数据

请求示例

# -*- coding: utf-8 -*-
from __future__ import print_function

import ssl, hmac, base64, hashlib
from datetime import datetime as pydatetime

try:
    from urllib import urlencode
    from urllib2 import Request, urlopen
except ImportError:
    from urllib.parse import urlencode
    from urllib.request import Request, urlopen

# 云市场分配的密钥Id
secretId = "xxxx"
# 云市场分配的密钥Key
secretKey = "xxxx"
source = "market"

# 签名
datetime = pydatetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT')
signStr = "x-date: %s\nx-source: %s" % (datetime, source)
sign = base64.b64encode(hmac.new(secretKey.encode('utf-8'), signStr.encode('utf-8'), hashlib.sha1).digest())
auth = 'hmac id="%s", algorithm="hmac-sha1", headers="x-date x-source", signature="%s"' % (secretId, sign.decode('utf-8'))

# 请求方法
method = 'GET'
# 请求头
headers = {
    'X-Source': source,
    'X-Date': datetime,
    'Authorization': auth,
}
# 查询参数
queryParams = {
    'carid': '2571'}
# body参数(POST方法下存在)
bodyParams = {
}
# url参数拼接
url = 'https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/detail'
if len(queryParams.keys()) > 0:
    url = url + '?' + urlencode(queryParams)

request = Request(url, headers=headers)
request.get_method = lambda: method
if method in ('POST', 'PUT', 'PATCH'):
    request.data = urlencode(bodyParams).encode('utf-8')
    request.add_header('Content-Type', 'application/x-www-form-urlencoded')
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
response = urlopen(request, context=ctx)
content = response.read()
if content:
    print(content.decode('utf-8'))
curl -v -X GET https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/detail ?carid=2571-H 'Host:service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com' -H 'Source:source' -H 'Date:Mon, 19 Mar 2018 12:08:40 GMT' -H 'Authorization:hmac id = "AKIDi6qE41WgJ9w8h4h9zq68Vq24d1beIuN0qIwU", algorithm = "hmac-sha1", headers = "date source", signature = yMCxXNytW5nvVGNZ8aBtRxmiLJ4=' -H 'X-Requested-With:XMLHttpRequest' 
//请用云市场分配给您的密钥计算签名并放入请求头,Date为当前的GMT时间
<?php
// 云市场分配的密钥Id
$secretId = 'xxxx';
// 云市场分配的密钥Key
$secretKey = 'xxxx';
$source = 'market';

// 签名
$datetime = gmdate('D, d M Y H:i:s T');
$signStr = sprintf("x-date: %s\nx-source: %s", $datetime, $source);
$sign = base64_encode(hash_hmac('sha1', $signStr, $secretKey, true));
$auth = sprintf('hmac id="%s", algorithm="hmac-sha1", headers="x-date x-source", signature="%s"', $secretId, $sign);

// 请求方法
$method = 'GET';
// 请求头
$headers = array(
    'X-Source' => $source,
    'X-Date' => $datetime,
    'Authorization' => $auth,
);
// 查询参数
$queryParams = array (
    'carid' => '2571',
);
// body参数(POST方法下)
$bodyParams = array (
);
// url参数拼接
$url = 'https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/detail';
if (count($queryParams) > 0) {
    $url .= '?' . http_build_query($queryParams);
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_HTTPHEADER, array_map(function ($v, $k) {
    return $k . ': ' . $v;
}, array_values($headers), array_keys($headers)));
if (in_array($method, array('POST', 'PUT', 'PATCH'), true)) {
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($bodyParams));
}

$data = curl_exec($ch);
if (curl_errno($ch)) {
    echo "Error: " . curl_error($ch);
} else {
    print_r($data);
}
curl_close($ch);
/**
 * npm install crypto-js request
 */
var CryptoJS = require("crypto-js");
var request = require('request');
var querystring = require('querystring');

// 云市场分配的密钥Id
var secretId = "xxx";
// 云市场分配的密钥Key
var secretKey = "xxx";
var source = "market";

// 签名
var datetime = (new Date()).toGMTString();
var signStr = "x-date: " + datetime + "\n" + "x-source: " + source;
var sign = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA1(signStr, secretKey))
var auth = 'hmac id="' + secretId + '", algorithm="hmac-sha1", headers="x-date x-source", signature="' + sign + '"';

// 请求方法
var method = 'GET';
// 请求头
var headers = {
    "X-Source": source,
    "X-Date": datetime,
    "Authorization": auth,
}
// 查询参数
var queryParams = {
    'carid': '2571'}
// body参数(POST方法下)
var bodyParams = {
}
// url参数拼接
var url = 'https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/detail';
if (Object.keys(queryParams).length > 0) {
    url += '?' + querystring.stringify(queryParams);
}

var options = {
    url: url,
    timeout: 5000,
    method: method,
    headers: headers
}
if (['POST', 'PUT', 'PATCH'].indexOf(method) != -1) {
    options['body'] = querystring.stringify(bodyParams);
    options['headers']['Content-Type'] = "application/x-www-form-urlencoded";
}

request(options, function (error, response, body) {
    if (error !== null) {
        console.log('error:', error);
        return;
    }
    console.log(body);
});
package main

import (
    "crypto/hmac"
    "crypto/sha1"
    "encoding/base64"
    "fmt"
    "io"
    "io/ioutil"
    "net/http"
    gourl "net/url"
    "strings"
    "time"
)

func calcAuthorization(source string, secretId string, secretKey string) (auth string, datetime string, err error) {
    timeLocation, _ := time.LoadLocation("Etc/GMT")
    datetime = time.Now().In(timeLocation).Format("Mon, 02 Jan 2006 15:04:05 GMT")
    signStr := fmt.Sprintf("x-date: %s\nx-source: %s", datetime, source)

    // hmac-sha1
    mac := hmac.New(sha1.New, []byte(secretKey))
    mac.Write([]byte(signStr))
    sign := base64.StdEncoding.EncodeToString(mac.Sum(nil))

    auth = fmt.Sprintf("hmac id=\"%s\", algorithm=\"hmac-sha1\", headers=\"x-date x-source\", signature=\"%s\"",
        secretId, sign)

    return auth, datetime, nil
}

func urlencode(params map[string]string) string {
    var p = gourl.Values{}
    for k, v := range params {
        p.Add(k, v)
    }
    return p.Encode()
}

func main() {
    // 云市场分配的密钥Id
    secretId := "xxxx"
    // 云市场分配的密钥Key
    secretKey := "xxxx"
    source := "market"

    // 签名
    auth, datetime, _ := calcAuthorization(source, secretId, secretKey)

    // 请求方法
    method := "GET"
    // 请求头
    headers := map[string]string{"X-Source": source, "X-Date": datetime, "Authorization": auth}

    // 查询参数
    queryParams := make(map[string]string)
    queryParams["carid"] = "2571"
    // body参数
    bodyParams := make(map[string]string)

    // url参数拼接
    url := "https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/detail"
    if len(queryParams) > 0 {
        url = fmt.Sprintf("%s?%s", url, urlencode(queryParams))
    }

    bodyMethods := map[string]bool{"POST": true, "PUT": true, "PATCH": true}
    var body io.Reader = nil
    if bodyMethods[method] {
        body = strings.NewReader(urlencode(bodyParams))
        headers["Content-Type"] = "application/x-www-form-urlencoded"
    }

    client := &http.Client{
        Timeout: 5 * time.Second,
    }
    request, err := http.NewRequest(method, url, body)
    if err != nil {
        panic(err)
    }
    for k, v := range headers {
        request.Header.Set(k, v)
    }
    response, err := client.Do(request)
    if err != nil {
        panic(err)
    }
    defer response.Body.Close()

    bodyBytes, err := ioutil.ReadAll(response.Body)
    if err != nil {
        panic(err)
    }
    fmt.Println(string(bodyBytes))
}
using System.IO;
using System.Text;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System;


public class CsharpTest
{
    public static String HMACSHA1Text(String EncryptText, String EncryptKey)
    {
            HMACSHA1 hmacsha1 = new HMACSHA1();
            hmacsha1.Key = System.Text.Encoding.UTF8.GetBytes(EncryptKey);

            byte[] dataBuffer = System.Text.Encoding.UTF8.GetBytes(EncryptText);
            byte[] hashBytes = hmacsha1.ComputeHash(dataBuffer);
            return Convert.ToBase64String(hashBytes);
    }

    public static void Main(String[] args)
    {
        String url = "https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/detail";
        String method = "GET";
        String querys = "carid=2571";
        String source = "market";

        //云市场分配的密钥Id
        String  secretId = "xxx";
        //云市场分配的密钥Key
        String  secretKey = "xxx";

        String dt = DateTime.UtcNow.GetDateTimeFormats('r')[0];
        url = url + "?" + querys;

        String signStr = "x-date: " + dt + "\n" + "x-source: " + source;
        String sign = HMACSHA1Text(signStr, secretKey);

        String auth = "hmac id=\"" + secretId + "\", algorithm=\"hmac-sha1\", headers=\"x-date x-source\", signature=\"";
        auth = auth + sign + "\"";
        Console.WriteLine(auth + "\n");

        HttpWebRequest httpRequest = null;
        HttpWebResponse httpResponse = null;

        if (url.Contains("https://"))
        {
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
            httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
        }
        else
        {
            httpRequest = (HttpWebRequest)WebRequest.Create(url);
        }

        httpRequest.Method = method;
        httpRequest.Headers.Add("Authorization", auth);
        httpRequest.Headers.Add("X-Source", source);
        httpRequest.Headers.Add("X-Date", dt);

        try
        {
            httpResponse = (HttpWebResponse)httpRequest.GetResponse();
        }
        catch (WebException ex)
        {
            httpResponse = (HttpWebResponse)ex.Response;
        }

        Console.WriteLine(httpResponse.StatusCode);
        Console.WriteLine(httpResponse.Headers);
        Stream st = httpResponse.GetResponseStream();
        StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
        Console.WriteLine(reader.ReadToEnd());
        Console.WriteLine("\n");

    }

    public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
    {
        return true;
    }
}
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

import sun.misc.BASE64Encoder;


class Demo {
    public static String calcAuthorization(String source, String secretId, String secretKey, String datetime)
            throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
        String signStr = "x-date: " + datetime + "\n" + "x-source: " + source;
        Mac mac = Mac.getInstance("HmacSHA1");
        Key sKey = new SecretKeySpec(secretKey.getBytes("UTF-8"), mac.getAlgorithm());
        mac.init(sKey);
        byte[] hash = mac.doFinal(signStr.getBytes("UTF-8"));
        String sig = new BASE64Encoder().encode(hash);

        String auth = "hmac id=\"" + secretId + "\", algorithm=\"hmac-sha1\", headers=\"x-date x-source\", signature=\"" + sig + "\"";
        return auth;
    }

    public static String urlencode(Map<?, ?> map) throws UnsupportedEncodingException {
        StringBuilder sb = new StringBuilder();
        for (Map.Entry<?, ?> entry : map.entrySet()) {
            if (sb.length() > 0) {
                sb.append("&");
            }
            sb.append(String.format("%s=%s",
                    URLEncoder.encode(entry.getKey().toString(), "UTF-8"),
                    URLEncoder.encode(entry.getValue().toString(), "UTF-8")
            ));
        }
        return sb.toString();
    }

    public static void main(String[] args) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
        //云市场分配的密钥Id
        String secretId = "xxxx";
        //云市场分配的密钥Key
        String secretKey = "xxxx";
        String source = "market";

        Calendar cd = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
        String datetime = sdf.format(cd.getTime());
        // 签名
        String auth = calcAuthorization(source, secretId, secretKey, datetime);
        // 请求方法
        String method = "GET";
        // 请求头
        Map<String, String> headers = new HashMap<String, String>();
        headers.put("X-Source", source);
        headers.put("X-Date", datetime);
        headers.put("Authorization", auth);

        // 查询参数
        Map<String, String> queryParams = new HashMap<String, String>();
        queryParams.put("carid", "2571");
        // body参数
        Map<String, String> bodyParams = new HashMap<String, String>();

        // url参数拼接
        String url = "https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/detail";
        if (!queryParams.isEmpty()) {
            url += "?" + urlencode(queryParams);
        }

        BufferedReader in = null;
        try {
            URL realUrl = new URL(url);
            HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
            conn.setConnectTimeout(5000);
            conn.setReadTimeout(5000);
            conn.setRequestMethod(method);

            // request headers
            for (Map.Entry<String, String> entry : headers.entrySet()) {
                conn.setRequestProperty(entry.getKey(), entry.getValue());
            }

            // request body
            Map<String, Boolean> methods = new HashMap<>();
            methods.put("POST", true);
            methods.put("PUT", true);
            methods.put("PATCH", true);
            Boolean hasBody = methods.get(method);
            if (hasBody != null) {
                conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

                conn.setDoOutput(true);
                DataOutputStream out = new DataOutputStream(conn.getOutputStream());
                out.writeBytes(urlencode(bodyParams));
                out.flush();
                out.close();
            }

            // 定义 BufferedReader输入流来读取URL的响应
            in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String line;
            String result = "";
            while ((line = in.readLine()) != null) {
                result += line;
            }

            System.out.println(result);
        } catch (Exception e) {
            System.out.println(e);
            e.printStackTrace();
        } finally {
            try {
                if (in != null) {
                    in.close();
                }
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }
    }
}

正常返回示例

                                                                    {
    "status": 0,
    "msg": "ok",
    "result": {
        "id": "2571",
        "name": "2016款 Sportback 35TFSI 进取型",
        "initial": "A",
        "parentid": "220",
        "logo": "http://api.jisuapi.com/car/static/images/logo/300/2571.jpg",
        "price": "18.49万",
        "yeartype": "2016",
        "productionstate": "在产",
        "salestate": "在销",
        "sizetype": "紧凑型车",
        "depth": "4",
        "basic": {
            "price": "18.49万",
            "saleprice": "13.13万-18.47万",
            "warrantypolicy": "三年或10万公里",
            "vechiletax": "待查",
            "displacement": "1.4",
            "gearbox": "7档 双离合",
            "comfuelconsumption": "5.5",
            "userfuelconsumption": "",
            "officialaccelerationtime100": "8.4",
            "testaccelerationtime100": "",
            "maxspeed": "213",
            "seatnum": "5"
        },
        "body": {
            "color": "季风灰,#2c5866|莲花灰,#403e33|海南蓝,#4",
            "len": "4319",
            "width": "1785",
            "height": "1441",
            "wheelbase": "2629",
            "fronttrack": "",
            "reartrack": "",
            "weight": "1340",
            "fullweight": "",
            "mingroundclearance": "",
            "approachangle": "",
            "departureangle": "",
            "luggagevolume": "380",
            "luggagemode": "",
            "luggageopenmode": "掀背",
            "inductionluggage": "",
            "doornum": "5",
            "tooftype": "",
            "hoodtype": "",
            "roofluggagerack": "",
            "sportpackage": "无"
        },
        "engine": {
            "position": "前置",
            "model": "EA211",
            "displacement": "1.4",
            "displacementml": "1395",
            "intakeform": "涡轮增压",
            "cylinderarrangetype": "L型",
            "cylindernum": "4",
            "valvetrain": "4",
            "valvestructure": "双顶置凸轮(DOHC)",
            "compressionratio": "",
            "bore": "",
            "stroke": "",
            "maxhorsepower": "150",
            "maxpower": "110",
            "maxpowerspeed": "5000-6000",
            "maxtorque": "250",
            "maxtorquespeed": "1750-3000",
            "fueltype": "汽油",
            "fuelgrade": "97号",
            "fuelmethod": "直喷",
            "fueltankcapacity": "50",
            "cylinderheadmaterial": "铝合金",
            "cylinderbodymaterial": "铝合金",
            "environmentalstandards": "国4,京5",
            "startstopsystem": "有"
        },
        "gearbox": {
            "gearbox": "7档 双离合",
            "shiftpaddles": "选配"
        }
    }
}
                                                                

失败返回示例

                                                                    {
    "status": "202",
    "msg": "车型ID错误",
    "result": ""
}
                                                                

返回码定义

返回码
返回信息
描述
202
车型ID错误

获取所有品牌

调用地址:https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/brand

请求方式:GET

返回类型:HTML

API调用: API调用说明(secret_id & secret_key)

请求参数(Headers)

名称
类型
是否必须
描述
暂无数据

请求参数(Query)

名称
类型
是否必须
描述
暂无数据

请求参数(Body)

名称
类型
是否必须
描述
暂无数据

请求示例

# -*- coding: utf-8 -*-
from __future__ import print_function

import ssl, hmac, base64, hashlib
from datetime import datetime as pydatetime

try:
    from urllib import urlencode
    from urllib2 import Request, urlopen
except ImportError:
    from urllib.parse import urlencode
    from urllib.request import Request, urlopen

# 云市场分配的密钥Id
secretId = "xxxx"
# 云市场分配的密钥Key
secretKey = "xxxx"
source = "market"

# 签名
datetime = pydatetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT')
signStr = "x-date: %s\nx-source: %s" % (datetime, source)
sign = base64.b64encode(hmac.new(secretKey.encode('utf-8'), signStr.encode('utf-8'), hashlib.sha1).digest())
auth = 'hmac id="%s", algorithm="hmac-sha1", headers="x-date x-source", signature="%s"' % (secretId, sign.decode('utf-8'))

# 请求方法
method = 'GET'
# 请求头
headers = {
    'X-Source': source,
    'X-Date': datetime,
    'Authorization': auth,
}
# 查询参数
queryParams = {
}
# body参数(POST方法下存在)
bodyParams = {
}
# url参数拼接
url = 'https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/brand'
if len(queryParams.keys()) > 0:
    url = url + '?' + urlencode(queryParams)

request = Request(url, headers=headers)
request.get_method = lambda: method
if method in ('POST', 'PUT', 'PATCH'):
    request.data = urlencode(bodyParams).encode('utf-8')
    request.add_header('Content-Type', 'application/x-www-form-urlencoded')
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
response = urlopen(request, context=ctx)
content = response.read()
if content:
    print(content.decode('utf-8'))
curl -v -X GET https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/brand -H 'Host:service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com' -H 'Source:source' -H 'Date:Mon, 19 Mar 2018 12:08:40 GMT' -H 'Authorization:hmac id = "AKIDi6qE41WgJ9w8h4h9zq68Vq24d1beIuN0qIwU", algorithm = "hmac-sha1", headers = "date source", signature = yMCxXNytW5nvVGNZ8aBtRxmiLJ4=' -H 'X-Requested-With:XMLHttpRequest' 
//请用云市场分配给您的密钥计算签名并放入请求头,Date为当前的GMT时间
<?php
// 云市场分配的密钥Id
$secretId = 'xxxx';
// 云市场分配的密钥Key
$secretKey = 'xxxx';
$source = 'market';

// 签名
$datetime = gmdate('D, d M Y H:i:s T');
$signStr = sprintf("x-date: %s\nx-source: %s", $datetime, $source);
$sign = base64_encode(hash_hmac('sha1', $signStr, $secretKey, true));
$auth = sprintf('hmac id="%s", algorithm="hmac-sha1", headers="x-date x-source", signature="%s"', $secretId, $sign);

// 请求方法
$method = 'GET';
// 请求头
$headers = array(
    'X-Source' => $source,
    'X-Date' => $datetime,
    'Authorization' => $auth,
);
// 查询参数
$queryParams = array (
);
// body参数(POST方法下)
$bodyParams = array (
);
// url参数拼接
$url = 'https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/brand';
if (count($queryParams) > 0) {
    $url .= '?' . http_build_query($queryParams);
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_HTTPHEADER, array_map(function ($v, $k) {
    return $k . ': ' . $v;
}, array_values($headers), array_keys($headers)));
if (in_array($method, array('POST', 'PUT', 'PATCH'), true)) {
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($bodyParams));
}

$data = curl_exec($ch);
if (curl_errno($ch)) {
    echo "Error: " . curl_error($ch);
} else {
    print_r($data);
}
curl_close($ch);
/**
 * npm install crypto-js request
 */
var CryptoJS = require("crypto-js");
var request = require('request');
var querystring = require('querystring');

// 云市场分配的密钥Id
var secretId = "xxx";
// 云市场分配的密钥Key
var secretKey = "xxx";
var source = "market";

// 签名
var datetime = (new Date()).toGMTString();
var signStr = "x-date: " + datetime + "\n" + "x-source: " + source;
var sign = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA1(signStr, secretKey))
var auth = 'hmac id="' + secretId + '", algorithm="hmac-sha1", headers="x-date x-source", signature="' + sign + '"';

// 请求方法
var method = 'GET';
// 请求头
var headers = {
    "X-Source": source,
    "X-Date": datetime,
    "Authorization": auth,
}
// 查询参数
var queryParams = {
}
// body参数(POST方法下)
var bodyParams = {
}
// url参数拼接
var url = 'https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/brand';
if (Object.keys(queryParams).length > 0) {
    url += '?' + querystring.stringify(queryParams);
}

var options = {
    url: url,
    timeout: 5000,
    method: method,
    headers: headers
}
if (['POST', 'PUT', 'PATCH'].indexOf(method) != -1) {
    options['body'] = querystring.stringify(bodyParams);
    options['headers']['Content-Type'] = "application/x-www-form-urlencoded";
}

request(options, function (error, response, body) {
    if (error !== null) {
        console.log('error:', error);
        return;
    }
    console.log(body);
});
package main

import (
    "crypto/hmac"
    "crypto/sha1"
    "encoding/base64"
    "fmt"
    "io"
    "io/ioutil"
    "net/http"
    gourl "net/url"
    "strings"
    "time"
)

func calcAuthorization(source string, secretId string, secretKey string) (auth string, datetime string, err error) {
    timeLocation, _ := time.LoadLocation("Etc/GMT")
    datetime = time.Now().In(timeLocation).Format("Mon, 02 Jan 2006 15:04:05 GMT")
    signStr := fmt.Sprintf("x-date: %s\nx-source: %s", datetime, source)

    // hmac-sha1
    mac := hmac.New(sha1.New, []byte(secretKey))
    mac.Write([]byte(signStr))
    sign := base64.StdEncoding.EncodeToString(mac.Sum(nil))

    auth = fmt.Sprintf("hmac id=\"%s\", algorithm=\"hmac-sha1\", headers=\"x-date x-source\", signature=\"%s\"",
        secretId, sign)

    return auth, datetime, nil
}

func urlencode(params map[string]string) string {
    var p = gourl.Values{}
    for k, v := range params {
        p.Add(k, v)
    }
    return p.Encode()
}

func main() {
    // 云市场分配的密钥Id
    secretId := "xxxx"
    // 云市场分配的密钥Key
    secretKey := "xxxx"
    source := "market"

    // 签名
    auth, datetime, _ := calcAuthorization(source, secretId, secretKey)

    // 请求方法
    method := "GET"
    // 请求头
    headers := map[string]string{"X-Source": source, "X-Date": datetime, "Authorization": auth}

    // 查询参数
    queryParams := make(map[string]string)

    // body参数
    bodyParams := make(map[string]string)

    // url参数拼接
    url := "https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/brand"
    if len(queryParams) > 0 {
        url = fmt.Sprintf("%s?%s", url, urlencode(queryParams))
    }

    bodyMethods := map[string]bool{"POST": true, "PUT": true, "PATCH": true}
    var body io.Reader = nil
    if bodyMethods[method] {
        body = strings.NewReader(urlencode(bodyParams))
        headers["Content-Type"] = "application/x-www-form-urlencoded"
    }

    client := &http.Client{
        Timeout: 5 * time.Second,
    }
    request, err := http.NewRequest(method, url, body)
    if err != nil {
        panic(err)
    }
    for k, v := range headers {
        request.Header.Set(k, v)
    }
    response, err := client.Do(request)
    if err != nil {
        panic(err)
    }
    defer response.Body.Close()

    bodyBytes, err := ioutil.ReadAll(response.Body)
    if err != nil {
        panic(err)
    }
    fmt.Println(string(bodyBytes))
}
using System.IO;
using System.Text;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System;


public class CsharpTest
{
    public static String HMACSHA1Text(String EncryptText, String EncryptKey)
    {
            HMACSHA1 hmacsha1 = new HMACSHA1();
            hmacsha1.Key = System.Text.Encoding.UTF8.GetBytes(EncryptKey);

            byte[] dataBuffer = System.Text.Encoding.UTF8.GetBytes(EncryptText);
            byte[] hashBytes = hmacsha1.ComputeHash(dataBuffer);
            return Convert.ToBase64String(hashBytes);
    }

    public static void Main(String[] args)
    {
        String url = "https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/brand";
        String method = "GET";
        String querys = "";
        String source = "market";

        //云市场分配的密钥Id
        String  secretId = "xxx";
        //云市场分配的密钥Key
        String  secretKey = "xxx";

        String dt = DateTime.UtcNow.GetDateTimeFormats('r')[0];
        url = url + "?" + querys;

        String signStr = "x-date: " + dt + "\n" + "x-source: " + source;
        String sign = HMACSHA1Text(signStr, secretKey);

        String auth = "hmac id=\"" + secretId + "\", algorithm=\"hmac-sha1\", headers=\"x-date x-source\", signature=\"";
        auth = auth + sign + "\"";
        Console.WriteLine(auth + "\n");

        HttpWebRequest httpRequest = null;
        HttpWebResponse httpResponse = null;

        if (url.Contains("https://"))
        {
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
            httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
        }
        else
        {
            httpRequest = (HttpWebRequest)WebRequest.Create(url);
        }

        httpRequest.Method = method;
        httpRequest.Headers.Add("Authorization", auth);
        httpRequest.Headers.Add("X-Source", source);
        httpRequest.Headers.Add("X-Date", dt);

        try
        {
            httpResponse = (HttpWebResponse)httpRequest.GetResponse();
        }
        catch (WebException ex)
        {
            httpResponse = (HttpWebResponse)ex.Response;
        }

        Console.WriteLine(httpResponse.StatusCode);
        Console.WriteLine(httpResponse.Headers);
        Stream st = httpResponse.GetResponseStream();
        StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
        Console.WriteLine(reader.ReadToEnd());
        Console.WriteLine("\n");

    }

    public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
    {
        return true;
    }
}
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

import sun.misc.BASE64Encoder;


class Demo {
    public static String calcAuthorization(String source, String secretId, String secretKey, String datetime)
            throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
        String signStr = "x-date: " + datetime + "\n" + "x-source: " + source;
        Mac mac = Mac.getInstance("HmacSHA1");
        Key sKey = new SecretKeySpec(secretKey.getBytes("UTF-8"), mac.getAlgorithm());
        mac.init(sKey);
        byte[] hash = mac.doFinal(signStr.getBytes("UTF-8"));
        String sig = new BASE64Encoder().encode(hash);

        String auth = "hmac id=\"" + secretId + "\", algorithm=\"hmac-sha1\", headers=\"x-date x-source\", signature=\"" + sig + "\"";
        return auth;
    }

    public static String urlencode(Map<?, ?> map) throws UnsupportedEncodingException {
        StringBuilder sb = new StringBuilder();
        for (Map.Entry<?, ?> entry : map.entrySet()) {
            if (sb.length() > 0) {
                sb.append("&");
            }
            sb.append(String.format("%s=%s",
                    URLEncoder.encode(entry.getKey().toString(), "UTF-8"),
                    URLEncoder.encode(entry.getValue().toString(), "UTF-8")
            ));
        }
        return sb.toString();
    }

    public static void main(String[] args) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
        //云市场分配的密钥Id
        String secretId = "xxxx";
        //云市场分配的密钥Key
        String secretKey = "xxxx";
        String source = "market";

        Calendar cd = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
        String datetime = sdf.format(cd.getTime());
        // 签名
        String auth = calcAuthorization(source, secretId, secretKey, datetime);
        // 请求方法
        String method = "GET";
        // 请求头
        Map<String, String> headers = new HashMap<String, String>();
        headers.put("X-Source", source);
        headers.put("X-Date", datetime);
        headers.put("Authorization", auth);

        // 查询参数
        Map<String, String> queryParams = new HashMap<String, String>();

        // body参数
        Map<String, String> bodyParams = new HashMap<String, String>();

        // url参数拼接
        String url = "https://service-2fpjsoar-1257101137.ap-beijing.apigateway.myqcloud.com/release/car/brand";
        if (!queryParams.isEmpty()) {
            url += "?" + urlencode(queryParams);
        }

        BufferedReader in = null;
        try {
            URL realUrl = new URL(url);
            HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
            conn.setConnectTimeout(5000);
            conn.setReadTimeout(5000);
            conn.setRequestMethod(method);

            // request headers
            for (Map.Entry<String, String> entry : headers.entrySet()) {
                conn.setRequestProperty(entry.getKey(), entry.getValue());
            }

            // request body
            Map<String, Boolean> methods = new HashMap<>();
            methods.put("POST", true);
            methods.put("PUT", true);
            methods.put("PATCH", true);
            Boolean hasBody = methods.get(method);
            if (hasBody != null) {
                conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

                conn.setDoOutput(true);
                DataOutputStream out = new DataOutputStream(conn.getOutputStream());
                out.writeBytes(urlencode(bodyParams));
                out.flush();
                out.close();
            }

            // 定义 BufferedReader输入流来读取URL的响应
            in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String line;
            String result = "";
            while ((line = in.readLine()) != null) {
                result += line;
            }

            System.out.println(result);
        } catch (Exception e) {
            System.out.println(e);
            e.printStackTrace();
        } finally {
            try {
                if (in != null) {
                    in.close();
                }
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }
    }
}

正常返回示例

                                                                    {
    "status": 0,
    "msg": "ok",
    "result": [
        {
            "id": "1",
            "name": "奥迪",
            "initial": "A",
            "parentid": "0",
            "logo": "http://api.jisuapi.com/car/static/images/logo/300/1.png",
            "depth": "1"
        },
        {
            "id": "2",
            "name": "阿斯顿·马丁",
            "initial": "A",
            "parentid": "0",
            "logo": "http://api.jisuapi.com/car/static/images/logo/300/2.png",
            "depth": "1"
        },
        {
            "id": "3",
            "name": "阿尔法·罗密欧",
            "initial": "A",
            "parentid": "0",
            "logo": "http://api.jisuapi.com/car/static/images/logo/300/3.png",
            "depth": "1"
        },
        {
            "id": "4",
            "name": "AC Schnitzer",
            "initial": "A",
            "parentid": "0",
            "logo": "http://api.jisuapi.com/car/static/images/logo/300/4.png",
            "depth": "1"
        },
        {
            "id": "5",
            "name": "Artega",
            "initial": "A",
            "parentid": "0",
            "logo": "http://api.jisuapi.com/car/static/images/logo/300/5.png",
            "depth": "1"
        },
        {
            "id": "6",
            "name": "奥克斯",
            "initial": "A",
            "parentid": "0",
            "logo": "http://api.jisuapi.com/car/static/images/logo/300/6.png",
            "depth": "1"
        },
        {
            "id": "7",
            "name": "本田",
            "initial": "B",
            "parentid": "0",
            "logo": "http://api.jisuapi.com/car/static/images/logo/300/7.png",
            "depth": "1"
        }
    ]
}
                                                                

返回码定义

返回码
返回信息
描述
无参数

商品介绍

最新最全的车型车系大全、汽车标志大全。1级为车品牌,2级为车品牌子公司,3级为车型,4级为具体的车款。

使用指南

1购买完成后,点击进入控制台

2在控制台点击”管理“查看详情”

3获得API的SecretID和SecretKey后,即可按照商品介绍里的方式调用API

累计评价(0)

为保障您的权益,请勿线下交易!90%的欺诈、纠纷、资金盗窃均由线下交易导致。腾讯云市场为您提供以下服务保障:

优质服务商家

严格准入 提供海量上云服务

7*8小时在线客服

全程在线咨询 助您安心购物

专业测试保证品质

安全监测 保障商品质量

退款售后无忧

不满意可退款 保障售后无忧

卖家服务时间

为保障您的权益,请勿线下交易!90%的欺诈、纠纷、资金盗窃均由线下交易导致。