Exemple #1
0
        /// <summary>
        /// 发送语义理解请求
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="semanticPostData">语义理解请求需要post的数据</param>
        /// <returns></returns>
        public static BaseSemanticResultJson SemanticSend(string accessToken, SemanticPostData semanticPostData)
        {
            var urlFormat = "https://api.weixin.qq.com/semantic/semproxy/search?access_token={0}";

            //switch (semanticPostData.category)
            //{
            //    case "restaurant":
            //        BaseSemanticResultJson as
            //}

            return(CommonJsonSend.Send <Semantic_RestaurantResult>(accessToken, urlFormat, semanticPostData));
        }
        /// <summary>
        /// 发送语义理解请求
        /// </summary>
        /// <typeparam name="T">语意理解返回的结果类型,在 AdvancedAPIs/Semantic/SemanticResult </typeparam>
        /// <param name="accessTokenOrAppId"></param>
        /// <param name="semanticPostData">语义理解请求需要post的数据</param>
        /// <param name="timeOut">代理请求超时时间(毫秒)</param>
        /// <returns></returns>
        public static T SemanticSend <T>(string accessTokenOrAppId, SemanticPostData semanticPostData, int timeOut = Config.TIME_OUT) where T : WxJsonResult
        {
            return(ApiHandlerWapper.TryCommonApi(accessToken =>
            {
                var urlFormat = "https://api.weixin.qq.com/semantic/semproxy/search?access_token={0}";

                //switch (semanticPostData.category)
                //{
                //    case "restaurant":
                //        BaseSemanticResultJson as Semantic_RestaurantResult;
                //}

                return CommonJsonSend.Send <T>(accessToken, urlFormat, semanticPostData, timeOut: timeOut);
            }, accessTokenOrAppId));
        }
Exemple #3
0
        public static async Task <T> SemanticSendAsync <T>(string accessTokenOrAppId, SemanticPostData semanticPostData, int timeOut = Config.TIME_OUT)
            where T : WxJsonResult, new()
        {
            return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
            {
                var urlFormat = Config.ApiMpHost + "/semantic/semproxy/search?access_token={0}";

                //switch (semanticPostData.category)
                //{
                //    case "restaurant":
                //        BaseSemanticResultJson as Semantic_RestaurantResult;
                //}

                return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync <T>(accessToken, urlFormat, semanticPostData, timeOut: timeOut).ConfigureAwait(false);
            }, accessTokenOrAppId).ConfigureAwait(false));
        }