In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
This article describes how to send Wechat messages through PowerShell
First apply for WeCom (three types of enterprise, government and organization). Call WeCom's API mass sending API to send Wechat messages through PowerShell. For more information on API, please see WeCom developer's documentation.
The following is PowerShell calling WeCom API to send a text message
-Script File: send_WeChat.ps1
Param ($param1,$param2,$param3)
# # set a key with a length of 16-32 bits
Function Set-Key {
Param ([string] $string)
$length = $string.length
$pad = 32-$length
If (($length-lt 16)-or ($length-gt 32)) {Throw "String must be between 16 and 32 characters"}
$encoding = New-Object System.Text.ASCIIEncoding
$bytes = $encoding.GetBytes ($string + "0" * $pad)
Return $bytes
}
# # decryption method
Function Get-EncryptedData {
Param ($key,$data)
$data | ConvertTo-SecureString-key $key |
ForEach-Object {[Runtime.InteropServices.Marshal]:: PtrToStringAuto ([Runtime.InteropServices.Marshal]:: SecureStringToBSTR ($_))}
}
# # method of sending Wechat
Function send_WeChat_To_DBA {
Param (
[String] $corpid
[String] $pwd
[String] $Content
)
$auth_string = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$corpid&corpsecret=$pwd"
$auth_values = Invoke-RestMethod $auth_string
$token = $auth_values.access_token
$body= "{
`"toparty`":` "receive group id`"
`"agentid` ": `" your agent id` "
`"text` ": {
`"content`":` "$content`"
}
`"msgtype`":` "text`"
} "
$CN= [System.Text.Encoding]:: UTF8.GetBytes ($body)
Invoke-RestMethod "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$token"-ContentType" application/json "- Method Post-Body $CN
}
# # resolving account password
$cidstr= Get-Content E:\ Monitor\ cidstr.txt
$pwdstr = Get-Content E:\ Monitor\ keystr.txt
$cidkey = Set-Key $cidstr
$pwdkey = Set-Key $pwdstr
$cidfromFile = Get-Content E:\ Monitor\ wxcid.txt
$pwdfromFile = Get-Content E:\ Monitor\ wxpwd.txt
$corpid = Get-EncryptedData-data $cidfromFile-key $cidkey
$pwd = Get-EncryptedData-data $pwdfromFile-key $pwdkey
$content=$param1+$param2+$param3
# # calling the sending method
Send_WeChat_To_DBA-corpid $corpid-pwd $pwd-Content $content
# # how to call send_WeChat.ps1
E:\ Monitor\ send_WeChat.ps1 $param1 $param2 $param3
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.