企业微信通知流程

1.注册企业微信,企业有企业corpid,建立一个组,组内有个corpsecret
2.组内添加组员
3.发送一个get的https协议,根据企业corpid和组的corpsecret得到一个json数据,json数据内部有个access_token, 这个access_token过段时间会刷新一次。
https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid= &corpsecret=

CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");
  curl_easy_setopt(curl, CURLOPT_URL, "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=wwfad38a43e06e8581&corpsecret=QoE-ir3wy_P3xyWpzgc9aKmA3HZ29KgUMbMvDe4sw5s");
  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
  struct curl_slist *headers = NULL;
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
  res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);

4通过秘钥access_token,然后发送通过https去post一个json数据,即可实现
https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=

CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
  curl_easy_setopt(curl, CURLOPT_URL, "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=Bo5Nz7D3fJkLOcPKHwctSPU3FQmCXlrknQ3k7gK7WEIe7z2sCpTHOUukq5mGKBiOUi16zmfTpzbwM8zoNUu1j5QckQb7pJV6YXt9qTjAdZg_3WqJh7X3OjhXGvKlRNQ908Otf_JS4wTX3-W9gC6tRsGfnLEOwgeMZZabs-k093Dr0AsEVMbqzg66tEmO5DHnwPLn4u-tfhmDlKNAc7hbVw");
  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
  struct curl_slist *headers = NULL;
  headers = curl_slist_append(headers, "Content-Type: application/json");
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
  const char *data = "{
\n   \"touser\" : \"@all\",
\n   \"toparty\" : \"@all\",
\n   \"totag\" : \"@all\",
\n   \"msgtype\" : \"text\",
\n   \"agentid\" : 1000002,
\n   \"text\" : {
\n       \"content\" : \"你的快递已到,请携带工卡前往邮件中心领取。\\n出发前可查看<a href=\\\"http://work.weixin.qq.com\\\">邮件中心视频实况</a>,聪明避开排队。\"
\n   },
\n   \"safe\":0,
\n   \"enable_id_trans\": 0,
\n   \"enable_duplicate_check\": 0,
\n   \"duplicate_check_interval\": 1800
\n}";
  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
  res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);

C++推荐使用库 libcurl,
libcurl链接地址
openssl

cjson

cjson库链接地址

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值