使用REST API將資料上鏈時,我們可以通過Alibaba Content Security Service服務的整合,對上鏈內容進行前置檢查,避免違規資料上鏈。
下面以 Node.js 為例介紹如何使用REST API在資料上鏈前進行內容合規檢查。
前置條件
您需要先在區塊鏈執行個體中安裝雲端服務整合, 並開通Alibaba Content Security Service整合功能。
下載雲端服務整合範例程式碼。
本地安裝 Node.js v8 環境(>=8.17.0)。
使用方法
參考文檔使用REST API, 修改樣本
invoke-with-content-check中的 main.js。進入目錄
invoke-with-content-check安裝 node 依賴項npm install。使用
node main.js啟動樣本。
樣本輸出
Data 1581905807512 pushed to blockchain with transaction 284d0b2b89db5bc5489127de863d0bb9b9d0a5f05bae67762567a3aff113822a
Content Moderation check failed: Send transaction failed: CONTENT_CHECK returned error VERIFY_FAILED: Content Moderation Check failed, suggestion block. key: 1581905807512, value: <此處略去用於測試的低俗內容>
Content Moderation check failed: Send transaction failed: CONTENT_CHECK returned error VERIFY_FAILED: Content Moderation Check failed, suggestion block. key: 1581905807512, value: <此處略去用於測試的政治敏感內容>進階
如果預設的Alibaba Content Security Service檢查策略不能滿足您的業務要求,您可以登入Alibaba Content Security Service控制台,參考文檔自訂文本庫來擴充檢查規則或對上鏈內容檢查的行為進行調整。