一个用Go编写的快速xApi客户端实现

301 阅读1分钟

XGO-API

GitHub go.mod Go version of a Go module codecov

概述

XGO-API是一个用Golang编写的The Experience API(或xAPI)的客户端库实现。Repo还包括一个CLI工具,可以查询学习记录商店。

The Experience API (xAPI)

The Experience API(或称xAPI)是学习技术的一个新规范,它使收集一个人的各种经历(在线和离线)的数据成为可能。这个API以一致的格式从许多技术中捕捉到关于一个人或一个团体的活动的数据。非常不同的系统能够通过使用xAPI的简单词汇捕捉和分享这种活动流来进行安全的交流。

安装

go get github.com/burakkaraceylan/xapi-go@latest

模块使用

lrs, err := client.NewRemoteLRS(
	"https://cloud.scorm.com/ScormEngineInterface/TCAPI/public/",
	"1.0.0",
	"Basic VGVzdFVzZXI6cGFzc3dvcmQ=",
)

if err != nil {
	panic(err)
}

statement, err := lrs.GetStatement("b1893eed-14e6-4ac2-b154-3c6e828c2297")

if err != nil {
	panic(err)
}

pretty, err := statement.ToJson(true)

if err != nil {
	panic(err)
}

fmt.Println(pretty)

CLI使用方法

Usage:
xapi-go [flags]
xapi-go [command]

Available Commands:
completion   Generate the autocompletion script for the specified shell
getStatement 
help         Help about any command

Flags:
	--auth string       Authentication header (Basic, Bearer etc...)
	--endpoint string   URL of the API endpoint
-h, --help              help for xapi-go
	--password string   API user's password
	--username string   API user's username
	--version string    API version

Use "xapi-go [command] --help" for more information about a command.