绑定了企业微信后如何通过脚本给用户发企业微信消息
现在我们绑定了企业微信,我想通过脚本,给用户发企业微信消息,请问有相关的样例吗?后端脚本:
// 查询人员对象 里面有个qiyeweixinId字段
const person = this.org.getPerson( "这里人员标识" );
// 企业微信 accesstoken
var accessToken =com.x.base.core.project.config.Config.qiyeweixin().corpAccessToken();
// agentId
var agentId = com.x.base.core.project.config.Config.qiyeweixin().getAgentId();
// 发送消息地址
var sendUrl = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token="+accessToken;
// 企业微信消息格式 请参考 https://developer.work.weixin.qq ... F%E7%B1%BB%E5%9E%8B
var body = {
"touser" : personList.qiyeweixinId,
"msgtype" : "text",
"agentid" : agentId,
"text" : {
"content" : "这里是文字消息"
}
};
print(JSON.stringify(body))
var result = com.x.base.core.project.connection.HttpConnection.postAsString(sendUrl, null, JSON.stringify(body));
print(result);
飞龙在天 发表于 2024-5-24 11:21
后端脚本:
谢谢:handshake
页:
[1]