package
7.8.2
Repository: https://github.com/qiniu/api.v7.git
Documentation: pkg.go.dev

# README

Linking Cloud Server-Side Library for Go

Features

  • 设备管理

    • 添加新的设备: AddDevice(appid string, dev *Device)
    • 查询设备详细信息: QueryDevice(appid, device string)
    • 查询所有设备的列表: ListDevice(appid, prefix, marker string, limit int, online bool)
    • 查询设备的在线记录: ListDeviceHistoryactivity(appid, dev string, start, end int, marker string, limit int)
    • 更新设备配置: UpdateDevice(appid, device string, ops []PatchOperation)
    • 删除指定的设备: DeleteDevice(appid, device string)
  • 设备密钥管理

    • 新增设备密钥: AddDeviceKey(appid, device string)
    • 查询设备密钥: QueryDeviceKey(appid, device string)
    • 删除设备密钥: DeleteDeviceKey(appid, device, dak string)
    • 禁用、启用设备的密钥:UpdateDeviceKeyState(appid, device, dak string, state int)
    • 克隆设备: CloneDeviceKey(appid, fromdevice, todevice string, cleanSelfKeys, deleteDevice bool, deviceAccessKey string)
    • 通过设备 acceskey 查询设备 appid 和 device name: QueryAppidDeviceNameByAccessKey(dak string)
  • Vod

    • 视频片段查询: Segments(appid, device string, start, end int, marker string, limit int)
    • 视频片段进行收藏: Saveas(appid, device string, start, end int, fname, format string)
  • Dtoken

    • 视频回放/缩略图查询/倍速播放/延时直播/视频片段查询 Token 生成: VodToken(appid, device string, deadline int64)
    • 在线记录查询/设备查询 Token 生成: StatusToken(appid, device string, deadline int64)

Contents

Usage

Configuration

package main

import (
	// ...
	"github.com/qiniu/api.v7/v7/auth"
	"github.com/qiniu/api.v7/v7/linking"
)

var (
	AccessKey = "<QINIU ACCESS KEY>" // 替换成自己 Qiniu 账号的 AccessKey.
	SecretKey = "<QINIU SECRET KEY>" // 替换成自己 Qiniu 账号的 SecretKey.
	Appid   = "<Appid>"    // App 必须事先创建.
)

func main() {
	// ...
	mac := auth.New(testAccessKey, testSecretKey)
	manager := linking.NewManager(mac, nil)
	// ...
}

URL

Add Device

manager.AddDevice(Appid, dev)

Query Device

dev2, err := manager.QueryDevice(Appid, device)

List Device

devices, marker, err = manager.ListDevice(Appid, "sdk-testListDevice", "", 1000, false)

List Device history activity

segs, marker, err := manager.ListDeviceHistoryactivity(Appid, device, int(start), int(end), "", 1000)

Update Device

ops := []PatchOperation{
		PatchOperation{Op: "replace", Key: "segmentExpireDays", Value: 30},
	}
dev3, err := manager.UpdateDevice(Appid, device, ops)

Delete Device

manager.DeleteDevice(Appid, device)

Device Key

Add Device Key

manager.AddDeviceKey(Appid, device)

Query Deivce Key

keys, err := manager.QueryDeviceKey(Appid, device)

Delete Device Key

err := manager.DeleteDeviceKey(Appid, device, dak)

Update Device Key State

err = manager.UpdateDeviceKeyState(Appid, device, dak, 1)

Clone Device Key

keys, err := manager.CloneDeviceKey(Appid, device1, device2, false, false, dak1)

Query Appid Device By Device Key

appid, device, err := manager.QueryAppidDeviceNameByAccessKey(dak)

Vod

Get Segments

end := time.Now().Unix()
start := time.Now().Add(-time.Hour).Unix()
segs, marker, err := manager.Segments(Appid, device, int(start), int(end), "", 1000)

Saveas

end := time.Now().Unix()
start := time.Now().Add(-time.Hour).Unix()
saveasReply, _ := manager.Saveas(Appid, device, int(start), int(end), "testSaveas.mp4", "mp4")

Dtoken

Get Vod Token

token, err := manager.VodToken(Appid, device, time.Now().Add(time.Hour*5).Unix())
fmt.Println(token)

Get Status Token

time.Sleep(time.Second)
token, err := manager.VodToken(Appid, device, time.Now().Add(time.Hour*5).Unix())
noError(t, err)
fmt.Println(token)

视频播放相关 api 编程模型说明: 如用户请求视频相关api(例如:https://developer.qiniu.com/linking/api/5650/playback)时进行业务服务器中转,会造成访问路径比较长, 因此建议服务端只进行dtoken的签算并提供给播放端,播放端直接请求视频播放相关的API,提升播放体验。 具体下token签算参考 https://developer.qiniu.com/linking/api/5680/the-signature-in-the-url WeChatWorkScreenshot_c6c3e265-5ca3-48d9-8cc5-c40343506eeb

# Functions

New 初始化 Client.

# Variables

APIHost 指定了 API 服务器的地址.
APIHTTPScheme 指定了在请求 API 服务器时使用的 HTTP 模式.

# Structs

No description provided by the author
No description provided by the author
设备访问凭证.
----------------------------------------------------------------------------- 历史记录.
设备密钥管理.
No description provided by the author
No description provided by the author
No description provided by the author
Manager 代表一个 linking 用户的客户端.
No description provided by the author
No description provided by the author
----------------------------------------------------------------------------- mqtt rpc.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
查询活跃设备信息.

# Type aliases

No description provided by the author