Skip to content

获取轮播图

单设备允许上传5张图片资源,即接口最多返回给你5张图片。

TIP

请求接口(Header)必须携带参数,AppidAppSecret

请求方式(METHOD): POST
请求路径(URL): {url}/api/openapi/v1/banners
请求参数(Argsments): payload: base64code
注意: 默认查询条件: 已审核且可显示

Payload

参数类型说明必传
machine_nostring设备编号(定长8位数字字符串)
timestampstring当前时间戳

参数加密

对接示例

我们为您提供了2种语言 GO,PHP 的对接示例,如果您需要其他语言示例,请 联系我们

TIP

{url}默认为提供服务的地址

sh
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	json := []byte(`{"payload": "eyJtYWNoaW5lX25vIjoiODY2ODM4MDYy*******YxNzM5QiIsInRpbWVzdGFtcCI6IjE3MTMyNTE3MjYifQ=="}`)
	body := bytes.NewBuffer(json)
	
	// Create client
	client := &http.Client{}

	// Create request
	req, err := http.NewRequest("POST", "{url}/api/openapi/v1/banners", body)

	// Headers
	req.Header.Add("Appid", "ds*******")
	req.Header.Add("AppSecret", "********")

	parseFormErr := req.ParseForm()
	if parseFormErr != nil {
	  fmt.Println(parseFormErr)    
	}

	// Fetch Request
	resp, err := client.Do(req)
	
	if err != nil {
		fmt.Println("Failure : ", err)
	}

	// Read Response Body
	respBody, _ := io.ReadAll(resp.Body)

	// Display Results
	fmt.Println("response Status : ", resp.Status)
	fmt.Println("response Headers : ", resp.Header)
	fmt.Println("response Body : ", string(respBody))
}
php
<?php

// Include Guzzle. If using Composer:
// require 'vendor/autoload.php';

use GuzzleHttp\Pool;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;

$client = new Client();

$request = new Request(
        "POST",
        "{url}/api/openapi/v1/banners",
        [
            "Appid" => "ds*******************",
            "AppSecret" => "*******************",
        ],
        "{\"payload\":\"eyJtYWNoaW5lX25vIjoiODY2******jJBMjU5Q0IwMDYxNzM5QiIsInRpbWVzdGFtcCI6IjE3MTMyNTE3MjYifQ==\"}");

$response = $client->send($request);
echo "Response HTTP : " . $response->getStatusCode();

请求结果(成功)

将以上 AppidAppSecret 进行修改成您商户的内容,运行结果:

json
{
  "code": 0,
  "message": "ok",
  "data": [
    {
      "id": 2,
      "status": "APPROVED",
      "is_visible": true,
      "cover_image": "{url}/storage/BqoydfZzlk/8834b4af-5a50-45ca-ab07-1b376b2c0160.jpg",
      "sort_id": 2,
      "hit_count": 1,
      "views_count": 1
    },
    {
      "id": 11,
      "status": "APPROVED",
      "is_visible": true,
      "cover_image": "{url}/storage/BqoydfZzlk/8834b4af-5a50-45ca-ab07-1b376b2c0160.jpg",
      "sort_id": 1,
      "hit_count": 1,
      "views_count": 1
    }
  ]
}

TIP

注意: 因接口返回的字段使用 protobuf, 部分字段值为空 或 false 时,默认不传

参数类型说明必传
idint标识
statusstring审核状态(待审核,已审核)-
is_visibleboolean是否显示, 商户自己设置-
cover_imagestring附件的实际URL
sort_idint排序值
hit_countint点击数
views_countint展现数

查询结果为空时,data 默认返回空数组

json
{
  "code": 0,
  "message": "ok",
  "data": []
}

请求结果(失败)

根据返回的 错误代码 进行排查:

json
{
  "code": 30002,
  "message": "设备已离线",
  "data": {}
}

© All rights reserved. 广州鼎商金属制品有限公司