VAST 客户JS
Vast Client JS是一个JavaScript 库,用来获取和解析数字视频AdService模板(VAST)文档.
该图书馆提供三个组成部分:
- A 类 VAST 客户端 以获取和剖析 VAST XML 资源到 JavaScript Objects.
- A 类 VAST 解析器 直接解析 VAST XML.
- A 类 VAST 跟踪器 以批量和调用跟踪 URL.
API的完整文档都去 这里。 。 。 . 全班的参赛名单 这里
要探索如何在网络应用程序中执行 VAST 客户端的实用实例, 请访问此 链接此外,使用这个 链接 以学习如何在基本节点应用程序中使用 VAST 客户端.
遵守 VAST 4.3 规格 规定 互动广告局(IAB)。 。 。 .
开始
VAST客户JS作为国家防范机制软件包可供使用,并易于安装:
npm i @dailymotion/vast-client
然后导入所需的组件 .
VAST 客户端
如果您需要获取和解析 VAST 文档, 您可以使用 get 方法从 VAST 客户端数字 :
import { VASTClient } from '@dailymotion/vast-client'
const vastClient = new VASTClient();
vastClient.get('https://www.examplevast.com/vast.xml')
.then(parsedVAST => {
// Do something with the parsed VAST response
})
.catch(err => {
// Deal with the error
});
除了获取和解析 VAST 资源, VAST 客户端 提供了根据计数和执行时间过滤调用序列的选项,以及使用 URL 跟踪的可能性 VASTTRACER 软件。 。 。 .
如果您需要直接解析一个 VAST XML 并遵循任何包装链, 您可以使用 parseVAST 方法从 VAST 客户端 数字 :
import { VASTClient } from '@dailymotion/vast-client'
const vastClient = new VASTClient();
vastClient.parseVAST(vastXml)
.then(parsedVAST => {
// Do something with the parsed VAST response
})
.catch(err => {
// Deal with the error
});
VASTParser 软件
要直接解析 VAST XML 您可以使用 VASTParser 软件数字 : 这个 VASTParser 软件 将不获取, 最后的回复将只包含第一次遇到的 VAST .
import { VASTParser } from '@dailymotion/vast-client'
const vastParser = new VASTParser();
vastParser.parseVAST(vastXml)
.then(parsedVAST => {
// Do something with the parsed VAST response
})
.catch(err => {
// Deal with the error
});
VASTTRACER 软件
要追踪广告的执行,请创建 VASTTRACER 软件 实例并使用专用 方法 致电话 VAST 跟踪元素。 。 。 .
import { VASTTracker } from '@dailymotion/vast-client'
const vastTracker = new VASTTracker(vastClient, ad, creative);
// Track an impression for the given ad. Will call any <Impression> URI from the <InLine> and <Wrapper> tracking elements.
vastTracker.trackImpression();
API 文档
API文件按下列部分编排:
更改日志和迁移指南可见于 发布注释。 。 。 .
预先捆绑的版本
我们提供了客户端的几个预先捆绑的版本(参见: dist 目录(中文(简体) )
炸弹
使用包管理器添加 lib( 如 npm 或 rarn ) 时, 默认可以使用 js 捆绑器( 如 Web pack 或 rollup) 的版本 : vast-client.js 或者说 vast-client.min.js [删除].
const import {
VASTClient,
VASTParser,
VASTTracker
} from '@dailymotion/vast-client'
const vastClient = new VASTClient();
const vastParser = new VASTParser();
const vastTracker = new VASTTracker();
浏览器脚本
VAST客户JS预装版: vast-client.min.js [删除].
要使用它, 要么在您的CDN上主机, 要么在您的项目中本地运行 。 如果您使用脚本标记, 请确保将类型属性设置为下面的模块 .
您的索引.html
<script type="module" src="your-main-file.js"></script>
主语.js
import {VASTClient, VASTParser, VASTTracker} from "vast-client.min.js"
const vastClient = new VASTClient();
const vastParser = new VASTParser();
const vastTracker = new VASTTracker();
节点
节点预装版也可用: vast-client-node.js 或者说 vast-client-node.min.js [删除].
// Method 1: From npm
const VAST = require('@dailymotion/vast-client')
// Method 2: For pre-bundled you must copy first the file inside your project
// then you will be able to require it without the need of npm
const VAST = require('your/path/vast-client-node.min.js')
const vastClient = new VAST.VASTClient();
const vastParser = new VAST.VASTParser();
const vastTracker = new VAST.VASTTracker();
构建/贡献
见 捐款