微信企业号:shell定时发送图片 到 指定人
生活随笔
收集整理的這篇文章主要介紹了
微信企业号:shell定时发送图片 到 指定人
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #!/bin/bash #返回access?token function?getToken(){?#傳入?yún)?shù)$1為corpid,參數(shù)$2為corpsecret ????curl?-s?"https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$1&corpsecret=$2"?|?awk?-F?'"'?'{print?$4}' } #返回media_id function?getMediaId(){?#傳入?yún)?shù)$1為access?token;參數(shù)$2為圖片文件 ????curl?-s?-F?media=@$2?"https://qyapi.weixin.qq.com/cgi-bin/media/upload?access_token=$1&type=image"?|?awk?-F?'"'?'{print?$8}' } #發(fā)送文字消息 function?sendText(){?#傳入?yún)?shù)$1為access?token,$2為消息內(nèi)容,$3指定接收消息的賬號 ????curl?-d?'{"touser":?"'$3'",?"msgtype":?"text",?"agentid":?0,?"text":?{"content":?"'$2'"},?"safe":"0"}'??"https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$1" } #發(fā)送圖片消息 function?sendImage(){?#傳入?yún)?shù)$1為access?token;參數(shù)$2為media_id,$3指定接收消息的賬號 ????postdata='{"touser":?"'$3'",?"msgtype":?"image",?"agentid":?0,?"image":?{"media_id":?"'$2'"},?"safe":"0"}' ????curl?-d?"$postdata"??"https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$1" } corpid='xxxxxxxxxx'?#使用前面記下來的值替換 corpsecret='xxxxxxxxxxxxxxxxxxxxxxxxxxxxx'??#使用前面記下來的值替換 image='test.png' text='這是發(fā)送的內(nèi)容' receiver='mer_aqu'?#此處為接收者的id,根據(jù)企業(yè)號后臺的設置(ID),可以是手機號、微信號或其它的。同時發(fā)送到多個關(guān)注者用“|”隔開。 token=`getToken?$corpid?$corpsecret` sendText?$token?$text?$receiver media_id=`getMediaId?$token?$image` sendImage?$token?$media_id?$receiver |
本文轉(zhuǎn)自 295631788 51CTO博客,原文鏈接:http://blog.51cto.com/hequan/1899900,如需轉(zhuǎn)載請自行聯(lián)系原作者
總結(jié)
以上是生活随笔為你收集整理的微信企业号:shell定时发送图片 到 指定人的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 梭子鱼邮件归档设备配置
- 下一篇: 【iOS-cocos2d游戏引擎开发之一