1 Star 0 Fork 0

网易易盾 / antispam-csharp-demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
LiveVideoSolutionSubmitApiDemo.cs 2.76 KB
一键复制 编辑 原始数据 按行查看 历史
longfan 提交于 2022-06-06 11:37 . 缺失demo补充
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Net.Http;
namespace Com.Netease.Is.Antispam.Demo
{
class LiveVideoSolutionSubmitApiDemo
{
public static void liveVideoSubmit()
{
/** 产品密钥ID,产品标识 */
String secretId = "your_secret_id";
/** 产品私有密钥,服务端生成签名信息使用,请严格保管,避免泄露 */
String secretKey = "your_secret_key";
/** 易盾反垃圾直播音视频解决方案在线检测接口地址 */
String apiUrl = "http://as.dun.163.com/v3/livewallsolution/check";
Dictionary<String, String> parameters = new Dictionary<String, String>();
long curr = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;
String time = curr.ToString();
// 1.设置公共参数
parameters.Add("secretId", secretId);
parameters.Add("version", "v3");
parameters.Add("timestamp", time);
parameters.Add("nonce", new Random().Next().ToString());
// 2.设置私有参数
parameters.Add("dataId", "ebfcad1c-dba1-490c-b4de-e784c2691768");
parameters.Add("url", "http://xxx.xxx.com/xxxx");
// 3.生成签名信息
String signature = Utils.genSignature(secretKey, parameters);
parameters.Add("signature", signature);
// 4.发送HTTP请求
HttpClient client = Utils.makeHttpClient();
String result = Utils.doPost(client, apiUrl, parameters, 1000);
if(result != null)
{
JObject ret = JObject.Parse(result);
int code = ret.GetValue("code").ToObject<Int32>();
String msg = ret.GetValue("msg").ToObject<String>();
if (code == 200)
{
JObject resultObject = (JObject)ret["result"];
String taskId = resultObject["taskId"].ToObject<String>();
Boolean status = resultObject["status"].ToObject<Boolean>();
if (status)
{
Console.WriteLine(String.Format("SUBMIT SUCCESS: taskId={0}", taskId));
}
else
{
Console.WriteLine(String.Format("SUBMIT FAIL: taskId={0}", taskId));
}
}
else
{
Console.WriteLine(String.Format("ERROR: code={0}, msg={1}", code, msg));
}
}
else
{
Console.WriteLine("Request failed!");
}
}
}
}
1
https://gitee.com/netease_yidun/antispam-csharp-demo.git
git@gitee.com:netease_yidun/antispam-csharp-demo.git
netease_yidun
antispam-csharp-demo
antispam-csharp-demo
master

搜索帮助