예제 #1
0
        public virtual async Task <byte[]> CreateQRCodeAsync(string path, int width)
        {
            var access_token = await GetAccessTokenAsync();

            var requestUrl     = string.Format(CONSTANT.CREATEQRCODEURL, access_token);
            var requestContent = JsonConvert.SerializeObject(new { path = path, width = width });
            var res            = await _httpRepository.PostAsync(requestUrl, requestContent);

            return(Encoding.Default.GetBytes(res));
        }
예제 #2
0
        public virtual async Task <object> GetMaterialAsync(string media_id)
        {
            dynamic requestObject = new ExpandoObject();

            requestObject.media_id = media_id;

            var access_token = await _lazyWeChatBasic.GetAccessTokenAsync();

            var    url  = string.Format(CONSTANT.GETMATERIALURL, access_token, media_id);
            var    json = JsonConvert.SerializeObject(requestObject);
            string res  = await _httpRepository.PostAsync(url, json);

            if (res.Contains("down_url") || res.Contains("news_item"))
            {
                var returnObject = UtilRepository.ParseAPIResult(res);
                return(returnObject);
            }
            else
            {
                byte[] byteArray = Encoding.Default.GetBytes(res);
                return(byteArray);
            }
        }