xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

企业微信如何添加机器人 All In One

企业微信如何添加机器人 All In One

jira 问题同步到群里

https://weibanzhushou.com/blog/330#:~:text=开启企业微信内部群,可发现添加机器人按钮。

webhooks 调用地址

cURL

https://work.weixin.qq.com/help?doc_id=13376

$ curl 'http://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=633a31f6-7f9c-4bc4-97a0-xxx' \
   -H 'Content-Type: application/json' \
   -d '
   {
        "msgtype": "text",
        "text": {
            "content": "hello world"
        }
   }'

cURL to Fecth

fetch("http://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=633a31f6-7f9c-4bc4-97a0-xxx", {
  body: "\n   {\n        \"msgtype\": \"text\",\n        \"text\": {\n            \"content\": \"hello world\"\n        }\n   }",
  headers: {
    "Content-Type": "application/json"
  },
  method: "POST"
})

https://cdn.xgqfrms.xyz/curl-to-fetch/index.html

demos

const wxRobot = (params = {}, desc = '') => {
    // const witheList = ['xgqfrms',];
    const url = '/qywx/cgi-bin/webhook/send?key=???';
    // 测试 robot
    // const url_test = '/qywx/cgi-bin/webhook/send?key=???';
    const obj = {
        msgtype: 'markdown',
        markdown: {
            content: `
description: ${desc}\n
data: ${JSON.stringify(params, null, 4)}\n
            `,
        },
    };
    const options = new Blob(
        [JSON.stringify(obj)],
        {type : 'application/json'}
    );
    if(navigator.sendBeacon) {
        navigator.sendBeacon(url, options);
        // navigator.sendBeacon(url_test, options);
        // const {
        //     user,
        // } = params;
        // if(witheList.includes(user)) {
        //     navigator.sendBeacon(url_test, options);
        // }
    } else {
        // fallback
        fetch(
            url,
            {
                method: 'POST',
                mode: 'no-cors',
                headers: {
                    'Content-Type': 'application/json',
                },
                body: JSON.stringify(obj),
            },
        ).catch(err => console.log('fetch error', err)).finally(() => '');
    }
};

export {
    wxRobot,
};

// export default wxRobot;


(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

企业微信机器人

群机器人配置说明 - 企业微信API

https://work.weixin.qq.com/api/doc/90000/90136/91770

jira

https://jira.xgqfrms.xyz/secure/Dashboard.jspa

refs

https://github.com/xgqfrms/wx-robot-notice

https://zhuanlan.zhihu.com/p/66312814



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2021-03-31 11:26  xgqfrms  阅读(1717)  评论(8编辑  收藏  举报