Пример #1
0
 /// <summary>
 /// 设置用户备注名
 /// </summary>
 /// <param name="openid">用户标识</param>
 /// <param name="remark">新的备注名,长度必须小于30字符 </param>
 /// <param name="config"></param>
 /// <returns></returns>
 public static Task UpdateRemark(string openid, string remark, ApiConfig config = null)
 {
     return(ApiHelper.PostVoid("https://api.weixin.qq.com/cgi-bin/user/info/updateremark?$acac$", new { openid, remark }, config));
 }
Пример #2
0
 /// <summary>
 /// 新增临时素材. 临时素材只保留 3 天
 /// </summary>
 /// <param name="type">媒体文件类型,分别有图片(image)、语音(voice)、视频(video)和缩略图(thumb)</param>
 /// <param name="filename">文件名</param>
 /// <param name="dataStream">数据流</param>
 /// <param name="config"></param>
 /// <returns></returns>
 public static Task <UploadResult> Upload(string type, string filename, Stream dataStream, ApiConfig config = null)
 {
     return(ApiHelper.UploadResult <UploadResult>($"https://api.weixin.qq.com/cgi-bin/media/upload?$acac$&type={Uri.EscapeDataString(type)}", "media", filename, dataStream, null, config));
 }
Пример #3
0
 /// <summary>
 /// 发送 Post 请求, 返回字符串
 /// </summary>
 /// <param name="url">接口网址, 里边的 $acac$ 会被自动替换成 access_token=xxx </param>
 /// <param name="data">将会转换为 JSON 格式作为 Post 请求的正文内容</param>
 /// <param name="config"></param>
 /// <returns></returns>
 public static Task <string> PostString(string url, object data, ApiConfig config = null)
 {
     return(PostStringWithToken(url, data, config, null));
 }
Пример #4
0
 /// <summary>
 /// 自定义菜单查询接口
 /// </summary>
 /// <param name="config"></param>
 /// <returns></returns>
 public static Task <GetMenuResult> Get(ApiConfig config = null)
 {
     return(ApiHelper.GetResult <GetMenuResult>("https://api.weixin.qq.com/cgi-bin/menu/get?$acac$", config));
 }
Пример #5
0
 /// <summary>
 /// 创建个性化菜单
 /// </summary>
 /// <param name="button">一级菜单项, 1~3个</param>
 /// <param name="matchrule">匹配规则</param>
 /// <param name="config"></param>
 /// <returns></returns>
 public static Task <AddConditionalResult> AddConditional(Button[] button, MatchRule matchrule, ApiConfig config = null)
 {
     return(ApiHelper.PostResult <AddConditionalResult>("https://api.weixin.qq.com/cgi-bin/menu/addconditional?$acac$", new { button, matchrule }, config));
 }
Пример #6
0
 /// <summary>
 /// 删除个性化菜单
 /// </summary>
 /// <param name="menuid">菜单id</param>
 /// <param name="config"></param>
 /// <returns></returns>
 public static Task DeleteConditional(string menuid, ApiConfig config = null)
 {
     return(ApiHelper.PostVoid("https://api.weixin.qq.com/cgi-bin/menu/delconditional?$acac$", new { menuid }, config));
 }
Пример #7
0
 /// <summary>
 /// 自定义菜单创建接口
 /// </summary>
 /// <param name="button">一级菜单项, 1~3 个</param>
 /// <param name="config"></param>
 /// <returns></returns>
 public static Task Create(Button[] button, ApiConfig config = null)
 {
     return(ApiHelper.PostVoid("https://api.weixin.qq.com/cgi-bin/menu/create?$acac$", new { button }, config));
 }
Пример #8
0
 public JsapiTicketManager(ApiConfig config)
 {
     _config = config;
 }
Пример #9
0
 /// <summary>
 /// 邀请绑定客服帐号
 /// </summary>
 /// <param name="kf_account">完整客服帐号,格式为:帐号前缀@公众号微信号</param>
 /// <param name="invite_wx">接收绑定邀请的客服微信号</param>
 /// <param name="config"></param>
 public static Task InviteWorker(string kf_account, string invite_wx, ApiConfig config = null)
 {
     return(ApiHelper.PostVoid("https://api.weixin.qq.com/customservice/kfaccount/inviteworker?$acac$", new { kf_account, invite_wx }, config));
 }
Пример #10
0
 /// <summary>
 /// 获取用户基本信息(UnionID机制)
 /// </summary>
 /// <param name="openid">普通用户的标识,对当前公众号唯一</param>
 /// <param name="lang">返回国家地区语言版本,zh_CN 简体,zh_TW 繁体,en 英语</param>
 /// <param name="config"></param>
 /// <returns></returns>
 public static Task <GetInfoResult> GetInfo(string openid, string lang = "zh_CN", ApiConfig config = null)
 {
     return(ApiHelper.GetResult <GetInfoResult>($"https://api.weixin.qq.com/cgi-bin/user/info?$acac$&openid={Uri.EscapeDataString(openid)}&lang={Uri.EscapeDataString(lang)}", config));
 }
Пример #11
0
        /// <summary>
        /// 批量获取用户基本信息。最多支持一次拉取100条。
        /// </summary>
        /// <param name="openid">用户标识列表</param>
        /// <param name="lang">与用户标识对应的语言列表, null 代表全部使用 zh_CN</param>
        /// <param name="config"></param>
        /// <returns></returns>
        public static Task <BatchGetInfoResult> BatchGet(string[] openid, string[] lang = null, ApiConfig config = null)
        {
            var user_list = openid.Zip(lang ?? Enumerable.Repeat("zh_CN", openid.Length), (o, l) => new { openid = o, lang = l }).ToArray();

            return(ApiHelper.PostResult <BatchGetInfoResult>("https://api.weixin.qq.com/cgi-bin/user/info/batchget?$acac$", new { user_list }, config));
        }
Пример #12
0
 /// <summary>
 /// 获取用户身上的标签列表
 /// </summary>
 /// <param name="openid">用户标识</param>
 /// <param name="config"></param>
 /// <returns></returns>
 public static Task <GetTagIdListResult> GetTagIdList(string openid, ApiConfig config = null)
 {
     return(ApiHelper.PostResult <GetTagIdListResult>("https://api.weixin.qq.com/cgi-bin/tags/members/getidlist?$acac$", new { openid }, config));
 }
Пример #13
0
 /// <summary>
 /// 批量为用户取消标签
 /// </summary>
 /// <param name="openid_list">要取消标签的用户标识列表</param>
 /// <param name="tagid">要取消的标签id</param>
 /// <param name="config"></param>
 /// <returns></returns>
 public static Task BatchUntagging(string[] openid_list, int tagid, ApiConfig config = null)
 {
     return(ApiHelper.PostVoid("https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging?$acac$", new { openid_list, tagid }, config));
 }
Пример #14
0
 /// <summary>
 /// 获取标签下粉丝列表
 /// </summary>
 /// <param name="tagid">标签id</param>
 /// <param name="next_openid">第一个拉取的OPENID,不填默认从头开始拉取</param>
 /// <param name="config"></param>
 /// <returns></returns>
 public static Task <GetListByTagResult> GetListByTag(int tagid, string next_openid = null, ApiConfig config = null)
 {
     return(ApiHelper.PostResult <GetListByTagResult>("https://api.weixin.qq.com/cgi-bin/user/tag/get?$acac$", new { tagid, next_openid }, config));
 }
Пример #15
0
 /// <summary>
 /// 获取客服会话列表
 /// </summary>
 /// <param name="kf_account">完整客服帐号,格式为:帐号前缀@公众号微信号</param>
 /// <param name="config"></param>
 public static Task <GetSessionListResult> GetSessionList(string kf_account, ApiConfig config = null)
 {
     return(ApiHelper.GetResult <GetSessionListResult>("https://api.weixin.qq.com/customservice/kfsession/getsessionlist?$acac$&kf_account=" + Uri.EscapeDataString(kf_account), config));
 }
Пример #16
0
 /// <summary>
 /// 设置客服信息
 /// </summary>
 /// <param name="kf_account">完整客服帐号,格式为:帐号前缀@公众号微信号</param>
 /// <param name="nickname">客服昵称,最长16个字</param>
 /// <param name="config"></param>
 public static Task UpdateAccount(string kf_account, string nickname, ApiConfig config = null)
 {
     return(ApiHelper.PostVoid("https://api.weixin.qq.com/customservice/kfaccount/update?$acac$", new { kf_account, nickname }, config));
 }
Пример #17
0
 /// <summary>
 /// 获取客服会话列表
 /// </summary>
 /// <param name="config"></param>
 public static Task <GetWaitCaseResult> GetWaitCase(ApiConfig config = null)
 {
     return(ApiHelper.GetResult <GetWaitCaseResult>("https://api.weixin.qq.com/customservice/kfsession/getwaitcase?$acac$", config));
 }
Пример #18
0
 public static Task UploadHeadImg(string kf_account, string filename, Stream fileStream, ApiConfig config = null)
 {
     return(ApiHelper.UploadVoid("https://api.weixin.qq.com/customservice/kfaccount/uploadheadimg?$acac$&kf_account=" + Uri.EscapeDataString(kf_account),
                                 "media",
                                 filename,
                                 fileStream,
                                 null,
                                 config));
 }
Пример #19
0
 /// <summary>
 /// 测试用户与个性化菜单的匹配结果
 /// </summary>
 /// <param name="user_id">粉丝的OpenID,或粉丝的微信号</param>
 /// <param name="config"></param>
 /// <returns></returns>
 public static Task <TryMatchResult> TryMatch(string user_id, ApiConfig config)
 {
     return(ApiHelper.PostResult <TryMatchResult>("https://api.weixin.qq.com/cgi-bin/menu/trymatch?$acac$", new { user_id }, config));
 }
Пример #20
0
 /// <summary>
 /// 删除客服帐号
 /// </summary>
 /// <param name="kf_account">完整客服帐号,格式为:帐号前缀@公众号微信号</param>
 /// <param name="config"></param>
 public static Task DeleteAccount(string kf_account, ApiConfig config = null)
 {
     return(ApiHelper.GetVoid("https://api.weixin.qq.com/customservice/kfaccount/del?$acac$&kf_account=" + Uri.EscapeDataString(kf_account), config));
 }
Пример #21
0
 /// <summary>
 /// 获取自定义菜单配置接口
 /// </summary>
 /// <param name="config"></param>
 /// <returns></returns>
 public static Task <GetCurrentSelfmenuInfoResult> GetCurrentSelfmenuInfo(ApiConfig config = null)
 {
     return(ApiHelper.GetResult <GetCurrentSelfmenuInfoResult>("https://api.weixin.qq.com/cgi-bin/get_current_selfmenu_info?$acac$", config));
 }
Пример #22
0
 /// <summary>
 /// <para>获取聊天记录</para>
 /// <para>对某个时间段首次请求时 msgid 应为 1;</para>
 /// <para>若请求的 number 和返回的 number 一样,该时间段可能还有聊天记录未获取,将返回的 msgid 填进下次请求中;</para>
 /// <para>若请求的 number 和返回的 number 不一样,则该时间段的后续聊天记录获取完毕;</para>
 /// </summary>
 /// <param name="starttime">起始时间,unix时间戳</param>
 /// <param name="endtime">结束时间,unix时间戳,每次查询时段不能超过24小时</param>
 /// <param name="msgid">消息id顺序从小到大,从1开始</param>
 /// <param name="number">每次获取条数,最多10000条</param>
 /// <param name="config"></param>
 /// <returns></returns>
 public static Task <GetMsgListResult> GetMsgList(long starttime, long endtime, long msgid, int number, ApiConfig config = null)
 {
     return(ApiHelper.PostResult <GetMsgListResult>("https://api.weixin.qq.com/customservice/msgrecord/getmsglist?$acac$", new { starttime, endtime, msgid, number }, config));
 }
Пример #23
0
 /// <summary>
 /// <para>自定义菜单删除接口</para>
 /// <para>注意,在个性化菜单时,调用此接口会删除默认菜单及全部个性化菜单。</para>
 /// </summary>
 /// <param name="config"></param>
 /// <returns></returns>
 public static Task Delete(ApiConfig config = null)
 {
     return(ApiHelper.GetVoid("https://api.weixin.qq.com/cgi-bin/menu/delete?$acac$", config));
 }
Пример #24
0
 /// <summary>
 /// 获取客服基本信息
 /// </summary>
 public static Task <GetKfListResult> GetKfList(ApiConfig config = null)
 {
     return(ApiHelper.GetResult <GetKfListResult>("https://api.weixin.qq.com/cgi-bin/customservice/getkflist?$acac$", config));
 }
Пример #25
0
 /// <summary>
 /// 上传图片
 /// </summary>
 /// <param name="filename">图片文件名</param>
 /// <param name="dataStream">图片数据流</param>
 /// <param name="config"></param>
 /// <returns></returns>
 public static Task <UploadImageResult> UploadImage(string filename, Stream dataStream, ApiConfig config = null)
 {
     return(ApiHelper.UploadResult <UploadImageResult>("https://api.weixin.qq.com/cgi-bin/media/uploadimg?$acac$", "media", filename, dataStream, null, config));
 }
Пример #26
0
 /// <summary>
 /// 关闭会话
 /// </summary>
 /// <param name="kf_account">完整客服帐号,格式为:帐号前缀@公众号微信号</param>
 /// <param name="openid">粉丝的openid</param>
 /// <param name="config"></param>
 public static Task CloseSession(string kf_account, string openid, ApiConfig config = null)
 {
     return(ApiHelper.PostVoid("https://api.weixin.qq.com/customservice/kfsession/close?$acac$", new { kf_account, openid }, config));
 }
Пример #27
0
 /// <summary>
 /// 下载临时素材
 /// </summary>
 /// <param name="media_id">媒体文件ID</param>
 /// <param name="config"></param>
 /// <returns></returns>
 public static Task <Stream> Get(string media_id, ApiConfig config = null)
 {
     return(ApiHelper.GetStream($"https://api.weixin.qq.com/cgi-bin/media/get?$acac$&media_id={Uri.EscapeDataString(media_id)}", config));
 }
Пример #28
0
 /// <summary>
 /// 获取一个客户的会话,如果不存在,则kf_account为空。
 /// </summary>
 /// <param name="openid">粉丝的openid</param>
 /// <param name="config"></param>
 public static Task <GetSessionResult> GetSession(string openid, ApiConfig config = null)
 {
     return(ApiHelper.GetResult <GetSessionResult>("https://api.weixin.qq.com/customservice/kfsession/getsession?$acac$&openid=" + Uri.EscapeDataString(openid), config));
 }
Пример #29
0
        private static async Task <string> PostStringWithToken(string url, object data, ApiConfig config, AsyncOutParameter <string> token)
        {
            var stream = await PostStreamWithToken(url, data, config, token).ConfigureAwait(false);

            using (var reader = new StreamReader(stream, Encoding.UTF8))
            {
                return(await reader.ReadToEndAsync().ConfigureAwait(false));
            }
        }
Пример #30
0
 /// <summary>
 /// <para>公众号可通过本接口来获取帐号的关注者列表,关注者列表由一串OpenID(加密后的微信号,每个用户对每个公众号的OpenID是唯一的)组成。一次拉取调用最多拉取10000个关注者的OpenID,可以通过多次拉取的方式来满足需求。</para>
 /// <para>当公众号关注者数量超过10000时,可通过填写next_openid的值,从而多次拉取列表的方式来满足需求。具体而言,就是在调用接口时,将上一次调用得到的返回中的next_openid值,作为下一次调用中的next_openid值。</para>
 /// </summary>
 /// <param name="next_openid"></param>
 /// <param name="config"></param>
 /// <returns></returns>
 public static Task <GetOpenListResult> GetList(string next_openid = null, ApiConfig config = null)
 {
     return(ApiHelper.GetResult <GetOpenListResult>($"https://api.weixin.qq.com/cgi-bin/user/get?$acac$&next_openid={next_openid}", config));
 }