基于.Net平台C#的微信网页版API 您所在的位置:网站首页 webwechat 基于.Net平台C#的微信网页版API

基于.Net平台C#的微信网页版API

2023-04-19 09:09| 来源: 网络整理| 查看: 265

git上有很多类似的项目,但大多都是python和js的,为了便于.Net windows平台的使用,我重构了一个.Net版本的,已整理开源

https://github.com/leestar54/WebWeChatAPI.Net

WebWeChat.Net

基于.Net平台C#的微信网页版API

近期更新 实现API基础功能 开发运行环境

vs2015+.net4.0 framework

依赖项

json.net 4.0

Feature 最小依赖,使用简单 支持同步、基于事件回调的异步方法 对象间隔离,可以实例化无数客户端 简单使用

具体内容见源码,此处仅简单说明

static void Main(string[] args) { Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; client = new Client(); qrForm = new QrCodeForm(); client.ExceptionCatched += Client_ExceptionCatched; ; client.GetLoginQrCodeComplete += Client_GetLoginQrCodeComplete; ; client.CheckScanComplete += Client_CheckScanComplete; ; client.LoginComplete += Client_LoginComplete; ; client.BatchGetContactComplete += Client_BatchGetContactComplete; ; client.GetContactComplete += Client_GetContactComplete; ; client.MPSubscribeMsgListComplete += Client_MPSubscribeMsgListComplete; ; client.LogoutComplete += Client_LogoutComplete; ; client.ReceiveMsg += Client_ReceiveMsg; ; client.DelContactListComplete += Client_DelContactListComplete; ; client.ModContactListComplete += Client_ModContactListComplete; Console.WriteLine("小助手启动"); client.Start(); qrForm.ShowDialog(); Console.ReadLine(); client.Close(); Console.ReadLine(); client.Logout(); } 方法说明 /// /// 异步发送文字消息 /// /// 消息 /// 发送人UserName public void SendMsgAsync(string msg, string toUserName) /// /// 同步发送文字消息 /// /// 文字 /// 发送人UserName /// public SendMsgResponse SendMsg(string msg, string toUserName) /// /// 异步发送文件 /// /// 文件信息 /// 发送人UserName public void SendMsgAsync(FileInfo fileInfo, string toUserName) /// /// 同步发送文件,自动分块上传,文件较大可能会卡住进程,建议异步发送 /// /// 文件信息 /// 发送人UserName /// public SendMsgResponse SendMsg(FileInfo fileInfo, string toUserName) /// /// 获取头像,因为请求的时候需要带Cookie等相关参数,所以直接用新的http请求不行,务必使用客户端API来获取 /// /// 头像地址,例如/cgi-bin/mmwebwx-bin/webwxgeticon?seq=0&username=filehelper&skey=@crypt_372b266_540d016177e861740ee84fec697a3b01 /// 委托Action /// public void GetIconAsync(string url, Action action) /// /// 同步上传文件 /// /// 文件信息 /// public UploadMediaResponse UploadFile(FileInfo fileInfo) /// /// 同步修改备注 /// 注意:多次调用该接口会被封 /// /// 需要修改的备注名 /// 需要修改的联系人UserName /// public SimpleResponse RemarkName(string remarkName, string userName) /// /// 同步通过好友认证 /// /// sync中获得的申请信息 /// public SimpleResponse VerifyUser(RecommendInfo info) /// /// 同步顶置聊天 /// 注意:多次调用该接口会被封 /// /// 备注名,官方接口同时附带这个参数,我们也带上吧 /// 需要修改的联系人UserName /// public SimpleResponse TopContact(string remarkName, string userName) /// /// 同步取消顶置消息 /// /// 备注名,官方接口同时附带这个参数,我们也带上吧 /// 需要修改的联系人UserName /// public SimpleResponse UnTopContact(string remarkName, string userName) /// /// 群里移除用户,用IsOwner判断自己是不是群主,否则没有权限 /// /// /// 用户UserName,英文,分割 /// public UpdateChatRoomResponse RemoveChatRoomMember(string roomName, List delNameList) /// /// 添加用户到群聊 /// /// 群UserName /// 用户UserName,英文,分割 /// public UpdateChatRoomResponse AddChatRoomMember(string roomName, List addNameList) /// /// 创建群,调用完成,可以用返回的信息,通过GetBatchGetContact去获取群信息 /// /// UserName的list /// public CreateChatRoomResponse CreateChatRoom(List memberList) 参考

liuwons/wxBot

Urinx/WeixinBot

lbbniu/WebWechat



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有