tnblog
首页
视频
资源
登录

微信群发接口,预览接口测试号可用

2937人阅读 2021/12/8 10:40 总访问:555047 评论:0 收藏:0 手机
分类: .net


给所有人群发,或者是根据标签群发
测试号没有权限得

public ActionResult Index()
{
    string token = AccessTokenTools.GetToken();
    string json = JsonConvert.SerializeObject(new
    {
        filter = new
        {
            is_to_all = true
        },
        text = new
        {
            content = "hello"
        },
        msgtype = "text"
    });
    HttpClient httpClient = new HttpClient();
    StringContent stringContent = new StringContent(json);
    string result = httpClient.PostAsync("https://api.weixin.qq.com/cgi-bin/message/mass/sendall?access_token=" + token, stringContent)
            .Result.Content.ReadAsStringAsync().Result;

    Response.Write(result);
    return View();
}



预览接口
其他群发接口测试号都没有权限,预览接口可以成功

public ActionResult Index()
{
    string token = AccessTokenTools.GetToken();

    string json = JsonConvert.SerializeObject(new
    {
        touser = "用户的optionId",
        text = new
        {
            content = "hello"
        },
        msgtype = "text"
    });

    HttpClient httpClient = new HttpClient();

    StringContent stringContent = new StringContent(json);

    string result = httpClient.PostAsync("https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=" + token, stringContent)
            .Result.Content.ReadAsStringAsync().Result;

    Response.Write(result);


    return View();
}


欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739

评价
这一生多幸运赶上过你.
排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2024TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
欢迎加群交流技术