发送微信消息的一种方式

2025-5-29 13:12:33 已被微信限制,要下载他们的 app 接收消息


https://wxpusher.zjiecode.com/

class Message {

    $appToken = ""

    Message($token) {
        $this.appToken = $token
    }

    send([array]$uids , [string]$summary, [string]$content) {
        $body = @{
            "appToken" = $this.appToken
            "uids" = $uids
            "contentType" = 1 # 1 文本,2 html (body 内部分)
            "summary"  = $summary
            "content"  = $content
            "verifyPayType" = 0 # 0 是否仅发给订阅用户
        }

        $body = $body | ConvertTo-Json -Compress

        $url = "https://wxpusher.zjiecode.com/api/send/message"

        $result = Invoke-RestMethod -Method Post -Uri $url  -Headers @{"Content-Type" = "application/json"} -Body $body

        if($result.code -ne 1000){
            $msg = "[$($result.code)] $($result.msg)"
            throw [System.Exception]::new($msg)
        }
    }
}
上一篇
下一篇