GithubHelp home page GithubHelp logo

dingtalk.sdk.netcore's Introduction

DingtalkSDK.Netcore

一款使用C#/.NETCORE6.0 的钉钉sdk

1 配置群

电脑安装登录钉钉,随便找两个朋友,新建一个群(不用经过他们允许),然后新建一个 群机器人,再删除你的两个朋友就可以了,取得 webhook 和 secret.

image image image image image image

成功获得AccessToken和UserSecret。

2 配置与使用

配置AccessToken和UserSecret到下图指定位置 image 根据单元测试配置代码

        // IOC
        private ServiceCollection _services;
        private string _accessToken, _secret;
        private IConfigurationRoot _configuration;

        public UnitTests()
        {
            // 依赖注入
            _services = new ServiceCollection();
            _services.AddScoped<IDingtalkService, DingtalkService>();

            // Read Secret
            _configuration = new ConfigurationBuilder()
               .SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
               .AddJsonFile("appsettings.json")
               .AddUserSecrets<UnitTests>()
               .Build();

            _accessToken = _configuration["DingDing:accessToken"];
            _secret = _configuration["DingDing:secret"];
        }

        [TestMethod]
        public async Task TestMethod()
        {
            using (var sp = _services.BuildServiceProvider())
            {
                var dingtalkService = sp.GetRequiredService<IDingtalkService>();
                var response = await dingtalkService.SendNotificationAsync("test123",_accessToken,_secret);
                Console.WriteLine(response.Content);
                Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.OK);
            }
        }

3 使用结果

image

dingtalk.sdk.netcore's People

Contributors

memoryfraction avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.