コード例 #1
0
ファイル: MediaApi.cs プロジェクト: Nokecy/WeiXinMPSDK
        /// <summary>
        ///【异步方法】获取临时媒体文件
        /// </summary>
        /// <param name="accessTokenOrAppKey">调用接口凭证(AccessToken)或AppKey(根据AccessTokenContainer.BuildingKey(corpId, corpSecret)方法获得)</param>
        /// <param name="agentId"></param>
        /// <param name="mediaId"></param>
        /// <param name="stream"></param>
        public static async Task GetForeverMaterialAsync(string accessTokenOrAppKey, int agentId, string mediaId, Stream stream)
        {
            await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var url =
                    string.Format(
                        Config.ApiWorkHost + "/cgi-bin/material/get?access_token={0}&media_id={1}&agentid={2}",
                        accessToken.AsUrlData(), mediaId.AsUrlData(), agentId);

                await Senparc.CO2NET.HttpUtility.Get.DownloadAsync(CommonDI.CommonSP, url, stream).ConfigureAwait(false);//todo 异常处理

                return(new WorkJsonResult()
                {
                    errcode = ReturnCode_Work.请求成功, errmsg = "ok"
                });
            }, accessTokenOrAppKey).ConfigureAwait(false);
        }
コード例 #2
0
ファイル: WxAppApi.cs プロジェクト: chenSean1/WeiXinMPSDK
        /// <summary>
        /// 【异步方法】获取小程序页面二维码
        /// </summary>
        /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
        /// <param name="stream">储存二维码的流</param>
        /// <param name="path">不能为空,最大长度 128 字节(如:pages/index?query=1,注:pages/index 需要在 app.json 的 pages 中定义)</param>
        /// <param name="width">二维码的宽度</param>
        /// <param name="timeOut">请求超时时间</param>
        /// <returns></returns>
        public static async Task <WxJsonResult> CreateWxQrCodeAsync(string accessTokenOrAppId, Stream stream, string path, int width = 430, int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                const string urlFormat = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token={0}";
                var url = string.Format(urlFormat, accessToken);

                var data = new { path = path, width = width };
                SerializerHelper serializerHelper = new SerializerHelper();
                await Post.DownloadAsync(url, serializerHelper.GetJsonString(data), stream);

                return new WxJsonResult()
                {
                    errcode = ReturnCode.请求成功
                };
            }, accessTokenOrAppId));
        }
コード例 #3
0
ファイル: WiFiApi.cs プロジェクト: huning1990/123
        public static async Task <WxJsonResult> SetFinishpageAsync(string accessTokenOrAppId, long shopId, string finishPageUrl,
                                                                   int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                string urlFormat = Config.ApiMpHost + "/bizwifi/finishpage/set?access_token={0}";

                var data = new
                {
                    shop_id = shopId,
                    finishpage_url = finishPageUrl
                };


                return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync <WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut).ConfigureAwait(false);
            }, accessTokenOrAppId).ConfigureAwait(false));
        }
コード例 #4
0
ファイル: GroupMessageApi.cs プロジェクト: jxsfm/WeiXinMPSDK
        /// <summary>
        /// 【异步方法】获取视频群发用的MediaId
        /// </summary>
        /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
        /// <param name="mediaId"></param>
        /// <param name="title"></param>
        /// <param name="description"></param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public static async Task <VideoMediaIdResult> GetVideoMediaIdResultAsync(string accessTokenOrAppId, string mediaId, string title,
                                                                                 string description, int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                string url = string.Format("https://file.api.weixin.qq.com/cgi-bin/media/uploadvideo?access_token={0}", accessToken.AsUrlData());

                var data = new
                {
                    media_id = mediaId,
                    title = title,
                    description = description
                };

                return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync <VideoMediaIdResult>(null, url, data, CommonJsonSendType.POST, timeOut, true);
            }, accessTokenOrAppId));
        }
コード例 #5
0
        public static async Task <ProductGetQrCodeJsonResult> GetQrCodeAsync(string accessTokenOrAppId, string keystr, string extinfo = null, string keystandard = "ean13", int qrcode_size = 100, int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var urlFormat = string.Format(Config.ApiMpHost + "/scan/product/getqrcode?access_token={0}", accessToken.AsUrlData());

                var data = new
                {
                    keystandard,
                    keystr,
                    extinfo,
                    qrcode_size
                };

                return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync <ProductGetQrCodeJsonResult>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut).ConfigureAwait(false);
            }, accessTokenOrAppId).ConfigureAwait(false));
        }
コード例 #6
0
ファイル: GroupsApi.cs プロジェクト: zongningliu/WeiXinMPSDK
        public static async Task <WxJsonResult> DeleteAsync(string accessTokenOrAppId, int groupId, int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var urlFormat = Config.ApiMpHost + "/cgi-bin/groups/delete?access_token={0}";

                var data = new
                {
                    group = new
                    {
                        id = groupId
                    }
                };

                return await CommonJsonSend.SendAsync <WxJsonResult>(accessToken, urlFormat, data, CommonJsonSendType.POST, timeOut);
            }, accessTokenOrAppId));
        }
コード例 #7
0
ファイル: CommentApi.cs プロジェクト: zongjijiang/WeiXinMPSDK
        public static Task <WxJsonResult> ReplyAddAsync(string accessTokenOrAppId, uint msg_data_id, uint?index, uint user_comment_id, string content, int timeOut = Config.TIME_OUT)
        {
            return(ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var urlFormat = Config.ApiMpHost + "/cgi-bin/comment/reply/add?access_token={0}";
                var data = new
                {
                    msg_data_id = msg_data_id,
                    index = index,
                    user_comment_id = user_comment_id,
                    content = content
                };

                JsonSetting jsonSetting = new JsonSetting(ignoreNulls: true);
                return await CommonJsonSend.SendAsync <WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting).ConfigureAwait(false);
            }, accessTokenOrAppId));
        }
コード例 #8
0
ファイル: CustomApi.cs プロジェクト: zengzhaoyuan/WeiXinMPSDK
        public static async Task <WxJsonResult> SendMusicAsync(string accessTokenOrAppId, string openId, string title, string description,
                                                               string musicUrl, string hqMusicUrl, string thumbMediaId, int timeOut = Config.TIME_OUT, string kfAccount = "")
        {
            object data = null;

            if (kfAccount.IsNullOrWhiteSpace())
            {
                data = new
                {
                    touser  = openId,
                    msgtype = "music",
                    music   = new
                    {
                        title          = title,
                        description    = description,
                        musicurl       = musicUrl,
                        hqmusicurl     = hqMusicUrl,
                        thumb_media_id = thumbMediaId
                    }
                };
            }
            else
            {
                data = new
                {
                    touser  = openId,
                    msgtype = "music",
                    music   = new
                    {
                        title          = title,
                        description    = description,
                        musicurl       = musicUrl,
                        hqmusicurl     = hqMusicUrl,
                        thumb_media_id = thumbMediaId
                    },
                    CustomService = new
                    {
                        kf_account = kfAccount
                    }
                };
            }
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync(accessToken, UrlFormat, data, timeOut: timeOut);
            }, accessTokenOrAppId));
        }
コード例 #9
0
ファイル: MediaApi.cs プロジェクト: ofood/WeChat
        public static async Task GetForeverMaterialAsync(string accessTokenOrAppKey, int agentId, string mediaId, Stream stream)
        {
            await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var url =
                    string.Format(
                        WxConfig.ApiWorkHost + "/cgi-bin/material/get?access_token={0}&media_id={1}&agentid={2}",
                        accessToken.AsUrlData(), mediaId.AsUrlData(), agentId);

                await OFoodWeChat.Infrastructure.Http.Get.DownloadAsync(url, stream);//todo 异常处理

                return(new WorkJsonResult()
                {
                    errcode = ReturnCode_Work.请求成功, errmsg = "ok"
                });
            }, accessTokenOrAppKey);
        }
コード例 #10
0
ファイル: WiFiApi.cs プロジェクト: zstep/WeiXinMPSDK
        /// <summary>
        ///【异步方法】 设置微信首页欢迎语

        /// </summary>
        /// <param name="accessTokenOrAppId"></param>
        /// <param name="shopId">门店ID</param>
        /// <param name="barType">微信首页欢迎语的文本内容:0--欢迎光临+公众号名称;1--欢迎光临+门店名称;2--已连接+公众号名称+WiFi;3--已连接+门店名称+Wi-Fi。</param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public static async Task <WxJsonResult> SetBarAsync(string accessTokenOrAppId, long shopId, int barType,
                                                            int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(accessToken =>
            {
                const string urlFormat = "https://api.weixin.qq.com/bizwifi/bar/set?access_token={0}";

                var data = new
                {
                    shop_id = shopId,
                    bar_type = barType
                };


                return Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync <WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
            }, accessTokenOrAppId));
        }
コード例 #11
0
ファイル: WxAppApi.cs プロジェクト: dean05/WeiXinMPSDK
        /// <summary>
        /// 【异步方法】获取小程序页面的小程序码
        /// </summary>
        /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
        /// <param name="stream">储存小程序码的流</param>
        /// <param name="path">不能为空,最大长度 128 字节(如:pages/index?query=1。注:pages/index 需要在 app.json 的 pages 中定义)</param>
        /// <param name="width">小程序码的宽度</param>
        /// <param name="auto_color">自动配置线条颜色</param>
        /// <param name="timeOut">请求超时时间</param>
        /// <returns></returns>
        public static async Task <WxJsonResult> GetWxaCodeAsync(string accessTokenOrAppId, Stream stream, string path, int width = 430, bool auto_color = false, int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                string urlFormat = Config.ApiMpHost + "/wxa/getwxacode?access_token={0}";
                var url = string.Format(urlFormat, accessToken);

                var data = new { path = path, width = width };
                SerializerHelper serializerHelper = new SerializerHelper();
                await Post.DownloadAsync(url, serializerHelper.GetJsonString(data), stream);

                return new WxJsonResult()
                {
                    errcode = ReturnCode.请求成功
                };
            }, accessTokenOrAppId));
        }
コード例 #12
0
        /// <summary>
        /// 【异步方法】删除标签
        /// </summary>
        /// <param name="accessTokenOrAppId"></param>
        /// <param name="id"></param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public static async Task <WxJsonResult> DeleteAsync(string accessTokenOrAppId, int id, int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(accessToken =>
            {
                var urlFormat = "https://api.weixin.qq.com/cgi-bin/tags/delete?access_token={0}";

                var data = new
                {
                    tag = new
                    {
                        id = id
                    }
                };

                return Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync <WxJsonResult>(accessToken, urlFormat, data, CommonJsonSendType.POST, timeOut);
            }, accessTokenOrAppId));
        }
コード例 #13
0
        /// <summary>
        ///【异步方法】获取临时媒体文件
        /// </summary>
        /// <param name="accessTokenOrAppKey"></param>
        /// <param name="agentId"></param>
        /// <param name="mediaId"></param>
        /// <param name="stream"></param>
        public static async Task GetForeverMaterialAsync(string accessTokenOrAppKey, int agentId, string mediaId, Stream stream)
        {
            await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var url =
                    string.Format(
                        "https://qyapi.weixin.qq.com/cgi-bin/material/get?access_token={0}&media_id={1}&agentid={2}",
                        accessToken.AsUrlData(), mediaId.AsUrlData(), agentId);

                await HttpUtility.Get.DownloadAsync(url, stream);//todo 异常处理

                return(new WorkJsonResult()
                {
                    errcode = ReturnCode_Work.请求成功, errmsg = "ok"
                });
            }, accessTokenOrAppKey);
        }
コード例 #14
0
        public static async Task <GetAgentResult> GetAgentAsync(string suiteAccessToken, string suiteId, string authCorpId, string permanentCode, string agentId, int timeOut = WxConfig.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var url = string.Format(WxConfig.ApiWorkHost + "/cgi-bin/service/get_agent?suite_access_token={0}", suiteAccessToken.AsUrlData());

                var data = new
                {
                    suite_id = suiteId,
                    auth_corpid = authCorpId,
                    permanent_code = permanentCode,
                    agentid = agentId
                };

                return await CommonJsonSend.SendAsync <GetAgentResult>(null, url, data, CommonJsonSendType.POST, timeOut);
            }, suiteAccessToken));
        }
コード例 #15
0
ファイル: WxAppApi.cs プロジェクト: hello-web/WXSDK
        /// <summary>
        /// 获取小程序页面的小程序码 不受限制
        /// </summary>
        /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
        /// <param name="stream">储存小程序码的流</param>
        /// <param name="scene">最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)</param>
        /// <param name="page">必须是已经发布的小程序页面,例如 "pages/index/index" ,根路径前不要填加'/',不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面</param>
        /// <param name="width">小程序码的宽度</param>
        /// <param name="auto_color">自动配置线条颜色</param>
        /// <param name="timeOut">请求超时时间</param>
        /// <returns></returns>
        public static async Task <WxJsonResult> GetWxaCodeUnlimitAsync(string accessTokenOrAppId, Stream stream, string scene, string page, int width = 430, bool auto_color = false, int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                const string urlFormat = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={0}";
                var url = string.Format(urlFormat, accessToken);

                var data = new { scene = scene, page = page, width = width };
                SerializerHelper serializerHelper = new SerializerHelper();
                await Post.DownloadAsync(url, serializerHelper.GetJsonString(data), stream);

                return new WxJsonResult()
                {
                    errcode = ReturnCode.请求成功
                };
            }, accessTokenOrAppId));
        }
コード例 #16
0
        /// <summary>
        /// 【异步方法】创建会话
        /// </summary>
        /// <param name="accessTokenOrAppKey">调用接口凭证(AccessToken)或AppKey(根据AccessTokenContainer.BuildingKey(corpId, corpSecret)方法获得)</param>
        /// <param name="chatId">会话id。字符串类型,最长32个字符。只允许字符0-9及字母a-zA-Z, 如果值内容为64bit无符号整型:要求值范围在[1, 2^63)之间,[2^63, 2^64)为系统分配会话id区间</param>
        /// <param name="name">会话标题</param>
        /// <param name="owner">管理员userid,必须是该会话userlist的成员之一</param>
        /// <param name="userlist">会话成员列表,成员用userid来标识。会话成员必须在3人或以上,1000人以下</param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public static async Task <QyJsonResult> CreateChatAsync(string accessTokenOrAppKey, string chatId, string name, string owner, string[] userlist, int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var url = string.Format("https://qyapi.weixin.qq.com/cgi-bin/chat/create?access_token={0}", accessToken.AsUrlData());

                var data = new
                {
                    chatid = chatId,
                    name = name,
                    owner = owner,
                    userlist = userlist
                };

                return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync <QyJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
            }, accessTokenOrAppKey));
        }
コード例 #17
0
ファイル: OaDataOpenApi.cs プロジェクト: yxlbyc/WeiXinMPSDK
        public static async Task <GetCheckinDataJsonResult> GetCheckinDataAsync(string accessTokenOrAppKey, OpenCheckinDataType openCheckinDataType, DateTime startTime, DateTime endTime, string[] userIdList, int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var url = Config.ApiWorkHost + "/cgi-bin/checkin/getcheckindata?access_token={0}";

                var data = new
                {
                    opencheckindatatype = (int)openCheckinDataType,
                    starttime = DateTimeHelper.GetWeixinDateTime(startTime),
                    endtime = DateTimeHelper.GetWeixinDateTime(endTime),
                    useridlist = userIdList
                };

                return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync <GetCheckinDataJsonResult>(accessToken, url, data, CommonJsonSendType.POST, timeOut);
            }, accessTokenOrAppKey));
        }
コード例 #18
0
ファイル: TemplateApi.cs プロジェクト: pony1688/WeiXinMPSDK
 /// <summary>
 /// 【异步方法】模板消息接口
 /// </summary>
 /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
 /// <param name="openId">填接收消息的用户openid</param>
 /// <param name="templateId">订阅消息模板ID</param>
 /// <param name="url">(非必须)点击消息跳转的链接,需要有ICP备案</param>
 /// <param name="data">消息正文,value为消息内容文本(200字以内),没有固定格式,可用\n换行,color为整段消息内容的字体颜色(目前仅支持整段消息为一种颜色)</param>
 /// <param name="miniProgram">(非必须)跳小程序所需数据,不需跳小程序可不用传该数据</param>
 /// <param name="timeOut">代理请求超时时间(毫秒)</param>
 /// <returns></returns>        /// <returns></returns>
 public static async Task <SendTemplateMessageResult> SendTemplateMessageAsync(string accessTokenOrAppId, string openId, string templateId, string url, object data, TemplateModel_MiniProgram miniProgram = null, int timeOut = Config.TIME_OUT)
 {
     return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
     {
         string urlFormat = Config.ApiMpHost + "/cgi-bin/message/template/send?access_token={0}";
         var msgData = new TemplateModel()
         {
             touser = openId,
             template_id = templateId,
             // topcolor = topcolor,
             url = url,
             miniprogram = miniProgram,
             data = data,
         };
         return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync <SendTemplateMessageResult>(accessToken, urlFormat, msgData, timeOut: timeOut).ConfigureAwait(false);
     }, accessTokenOrAppId).ConfigureAwait(false));
 }
コード例 #19
0
ファイル: WiFiApi.cs プロジェクト: huning1990/123
        public static async Task <WxJsonResult> AddDeviceAsync(string accessTokenOrAppId, long shopId, string ssid, string password,
                                                               /*string bssid,*/ int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                string urlFormat = Config.ApiMpHost + "/bizwifi/device/add?access_token={0}";

                var data = new
                {
                    shop_id = shopId,
                    ssid = ssid,
                    password = password,
                    //bssid = bssid,
                };
                return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync <WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut).ConfigureAwait(false);
            }, accessTokenOrAppId).ConfigureAwait(false));
        }
コード例 #20
0
        /// <summary>
        /// 【异步方法】设置企业号应用【Work中未定义】
        /// </summary>
        /// <param name="suiteAccessToken"></param>
        /// <param name="suiteId">应用套件id</param>
        /// <param name="authCorpId">授权方corpid</param>
        /// <param name="permanentCode">永久授权码,从get_permanent_code接口中获取</param>
        /// <param name="agent">要设置的企业应用的信息</param>
        /// <param name="timeOut">代理请求超时时间(毫秒)</param>
        /// <returns></returns>
        public static async Task <WorkJsonResult> SetAgentAsync(string suiteAccessToken, string suiteId, string authCorpId, string permanentCode, ThirdParty_AgentData agent, int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var url = string.Format(Config.ApiWorkHost + "/cgi-bin/service/set_agent?suite_access_token={0}", suiteAccessToken.AsUrlData());

                var data = new
                {
                    suite_id = suiteId,
                    auth_corpid = authCorpId,
                    permanent_code = permanentCode,
                    agent = agent
                };

                return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync <WorkJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut).ConfigureAwait(false);
            }, suiteAccessToken).ConfigureAwait(false));
        }
コード例 #21
0
        /// <summary>
        /// 【异步方法】获取图片、视频、语音素材列表
        /// </summary>
        /// <param name="accessTokenOrAppId"></param>
        /// <param name="type">素材的类型,图片(image)、视频(video)、语音 (voice)</param>
        /// <param name="offset"></param>
        /// <param name="count"></param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public static async Task <MediaList_OthersResult> GetOthersMediaListAsync(string accessTokenOrAppId, UploadMediaFileType type, int offset,
                                                                                  int count, int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(accessToken =>
            {
                string url = string.Format("https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token={0}", accessToken.AsUrlData());

                var date = new
                {
                    type = type.ToString(),
                    offset = offset,
                    count = count
                };

                return Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync <MediaList_OthersResult>(null, url, date, CommonJsonSendType.POST, timeOut);
            }, accessTokenOrAppId));
        }
コード例 #22
0
ファイル: MailListApi.cs プロジェクト: hlj671/WeiXinMP.SDK
        /// <summary>
        /// 【异步方法】更新部门
        /// </summary>
        /// <param name="accessTokenOrAppKey">调用接口凭证(AccessToken)或AppKey(根据AccessTokenContainer.BuildingKey(corpId, corpSecret)方法获得)</param>
        /// <param name="id">部门id</param>
        /// <param name="name">更新的部门名称。长度限制为0~64个字符。修改部门名称时指定该参数</param>
        /// <param name="parentId">父亲部门id。根部门id为1 </param>
        /// <param name="order">在父部门中的次序。从1开始,数字越大排序越靠后</param>
        /// <param name="timeOut">代理请求超时时间(毫秒)</param>
        /// <returns></returns>
        public static async Task <QyJsonResult> UpdateDepartmentAsync(string accessTokenOrAppKey, string id, string name, int parentId, int order = 1, int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var url = string.Format("https://qyapi.weixin.qq.com/cgi-bin/department/update?access_token={0}", accessToken.AsUrlData());

                var data = new
                {
                    id = id,
                    name = name,
                    parentid = parentId,
                    order = order
                };

                return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync <QyJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
            }, accessTokenOrAppKey));
        }
コード例 #23
0
ファイル: MediaApi.cs プロジェクト: yyiiss1987/Wchat-MP
        public static async Task <BatchGetMaterialResult> BatchGetMaterialAsync(string accessTokenOrAppKey, UploadMediaFileType type, int agentId, int offset, int count, int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var url = string.Format(Config.ApiWorkHost + "/cgi-bin/material/batchget?access_token={0}",
                                        accessToken.AsUrlData());

                var data = new
                {
                    type = type.ToString(),
                    agentid = agentId,
                    offset = offset,
                    count = count,
                };

                return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync <BatchGetMaterialResult>(null, url, data, CommonJsonSendType.POST, timeOut);
            }, accessTokenOrAppKey));
        }
コード例 #24
0
        public static async Task <WorkJsonResult> CreateMemberAsync(string accessTokenOrAppKey, MemberCreateRequest memberCreateRequest, int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var url = Config.ApiWorkHost + "/cgi-bin/user/create?access_token={0}";

                JsonSetting jsonSetting = new JsonSetting(true);
                return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync <WorkJsonResult>(accessToken, url, memberCreateRequest, CommonJsonSendType.POST, timeOut, jsonSetting: jsonSetting);

                /*
                 * 返回结果:
                 * {
                 *     "errcode": 0,
                 *     "errmsg": "created"
                 *  }
                 */
            }, accessTokenOrAppKey));
        }
コード例 #25
0
ファイル: AnalysisApi.cs プロジェクト: Sebastian1984/WeiXin
        public static async Task <AnalysisResultJson <ArticleSummaryItem> > GetArticleSummaryAsync(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                string urlFormat = Config.ApiMpHost + "/datacube/getarticlesummary?access_token={0}";

                var data = new
                {
                    begin_date = beginDate,
                    end_date = endDate
                };

                return await
                Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync <AnalysisResultJson <ArticleSummaryItem> >(
                    accessToken, urlFormat, data,
                    timeOut: timeOut);
            }, accessTokenOrAppId));
        }
コード例 #26
0
 /// <summary>
 /// 【异步方法】发送视频消息
 /// </summary>
 /// <param name="accessTokenOrAppId"></param>
 /// <param name="openId"></param>
 /// <param name="mediaId"></param>
 /// <param name="title"></param>
 /// <param name="description"></param>
 /// <param name="timeOut">代理请求超时时间(毫秒)</param>
 /// <returns></returns>
 public static async Task <WxJsonResult> SendVideoAsync(string accessTokenOrAppId, string openId, string mediaId, string title, string description, int timeOut = Config.TIME_OUT)
 {
     return(await ApiHandlerWapper.TryCommonApiAsync(accessToken =>
     {
         var data = new
         {
             touser = openId,
             msgtype = "video",
             video = new
             {
                 media_id = mediaId,
                 title = title,
                 description = description
             }
         };
         return Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync(accessToken, URL_FORMAT, data, timeOut: timeOut);
     }, accessTokenOrAppId));
 }
コード例 #27
0
ファイル: WiFiApi.cs プロジェクト: xydoublez/WeiXinMPSDK
        /// <summary>
        /// 【异步方法】数据统计
        /// </summary>
        /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
        /// <param name="beginDate">起始日期时间,格式yyyy-mm-dd,最长时间跨度为30天</param>
        /// <param name="endDate">结束日期时间戳,格式yyyy-mm-dd,最长时间跨度为30天</param>
        /// <param name="shopId">按门店ID搜索,-1为总统计</param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public static async Task <GetStatisticsResult> GetStatisticsAsync(string accessTokenOrAppId, string beginDate, string endDate,
                                                                          long shopId = -1,
                                                                          int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(accessToken =>
            {
                const string urlFormat = "https://api.weixin.qq.com/bizwifi/statistics/list?access_token={0}";

                var data = new
                {
                    begin_date = beginDate,
                    end_date = endDate,
                    shop_id = shopId,
                };

                return Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync <GetStatisticsResult>(accessToken, urlFormat, data, timeOut: timeOut);
            }, accessTokenOrAppId));
        }
コード例 #28
0
ファイル: MediaApi.cs プロジェクト: huning1990/123
        public static async Task <WxJsonResult> GetJssdkAsync(string accessTokenOrAppId, string mediaId, Stream stream, int timeOut = Config.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var urlFormat = string.Format(Config.ApiMpHost + "/cgi-bin/media/get/jssdk?access_token={0}&media_id={1}", accessToken.AsUrlData(), mediaId.AsUrlData());

                if (stream != null)
                {
                    stream.Seek(0, SeekOrigin.Begin);
                    await CO2NET.HttpUtility.Get.DownloadAsync(urlFormat, stream).ConfigureAwait(false);
                }

                return new WxJsonResult()
                {
                    errcode = ReturnCode.合法的媒体文件id, errmsg = "invalid media_id"
                };                                                                                         //错误情况下的返回
            }, accessTokenOrAppId).ConfigureAwait(false));
        }
コード例 #29
0
 public static async Task <WxJsonResult> BizSendAsync(string accessTokenOrAppId, string toUser, string templateId,
                                                      TemplateMessageData data, string page = null, TemplateModel_MiniProgram miniProgram = null,
                                                      int timeOut = Config.TIME_OUT)
 {
     return(await ApiHandlerWapper.TryCommonApiAsync(accessToken =>
     {
         string urlFormat = Config.ApiMpHost + "/cgi-bin/message/subscribe/bizsend?access_token={0}";
         var submitData = new
         {
             touser = toUser,
             template_id = templateId,
             page = page,
             data = data,
             miniprogram = miniProgram,
         };
         return CommonJsonSend.SendAsync(accessToken, urlFormat, submitData, timeOut: timeOut);
     }, accessTokenOrAppId));
 }
コード例 #30
0
        public static async Task <GetStatisticsResult> GetStatisticsAsync(string accessTokenOrAppId, string beginDate, string endDate,
                                                                          long shopId = -1,
                                                                          int timeOut = WxConfig.TIME_OUT)
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                string urlFormat = WxConfig.ApiMpHost + "/bizwifi/statistics/list?access_token={0}";

                var data = new
                {
                    begin_date = beginDate,
                    end_date = endDate,
                    shop_id = shopId,
                };

                return await CommonJsonSend.SendAsync <GetStatisticsResult>(accessToken, urlFormat, data, timeOut: timeOut);
            }, accessTokenOrAppId));
        }