private void button38_Click(object sender, EventArgs e) { //获取素材总数 MediaType type = (MediaType)Enum.Parse(typeof(MediaType), comboBox1.SelectedItem.ToString(), true); var result = WxHelperMedia.GetMediaList(accessToken, type, 0, 20); responseBox.Text = result.ToString(); }
private void button25_Click(object sender, EventArgs e) { //获取临时素材 var mediaid = textBox1.Text.Trim(); if (mediaid == "") { responseBox.Text = "请在第一个文本框中输入mediaid"; return; } string result = WxHelperMedia.DownloadMedia(accessToken, mediaid); responseBox.Text = result; }
private void button37_Click(object sender, EventArgs e) { //获取素材总数 var result = WxHelperMedia.GetMediaCount(accessToken); if (result.errcode == ReturnCode.请求成功) { responseBox.Text = result.errcode.ToString() + "\n"; responseBox.AppendText( "image_count:" + result.image_count + "\n" + "news_count:" + result.news_count + "\n" + "video_count:" + result.video_count + "\n" + "voice_count:" + result.voice_count + "\n" ); } else { responseBox.Text = result.errcode.ToString() + "\n" + result.errmsg.ToString(); } }
private void button34_Click(object sender, EventArgs e) { //上传图文消息内的图片获取URL if (openFileDialog1.FileName == "") { responseBox.Text = "请上传文件"; return; } MediaType type = (MediaType)Enum.Parse(typeof(MediaType), comboBox1.SelectedItem.ToString(), true); var result = WxHelperMedia.UploadImgGetUrl(accessToken, openFileDialog1.FileName); if (result.errcode == ReturnCode.请求成功) { responseBox.Text = result.errcode.ToString() + "\n"; responseBox.AppendText( "Url:" + result.url + "\n" ); } else { responseBox.Text = result.errcode.ToString() + "\n" + result.errmsg.ToString(); } }
private void button39_Click(object sender, EventArgs e) { //上传图文消息素材 List <UploadArticle> articles = new List <UploadArticle>(); UploadArticle article1 = new UploadArticle(); UploadArticle article2 = new UploadArticle(); article1.thumb_media_id = "MMg1Xg17qxzAdAPe8UZ7Aiej7_k4LvIXtC2eRmRRN9E"; article1.title = "图文消息1的标题"; article1.content_source_url = ""; article1.content = "图文消息页面的内容,支持HTML标签。具备微信支付权限的公众号,可以使用a标签,其他公众号不能使用"; article1.digest = ""; article1.show_cover_pic = "1"; article1.author = ""; article2.thumb_media_id = "MMg1Xg17qxzAdAPe8UZ7Aiej7_k4LvIXtC2eRmRRN9E"; article2.title = "图文消息2的标题"; article2.content_source_url = ""; article2.content = "图文消息页面的内容,支持HTML标签。具备微信支付权限的公众号,可以使用a标签,其他公众号不能使用"; article2.digest = ""; article2.show_cover_pic = "0"; article2.author = ""; articles.Add(article1); articles.Add(article2); var result = WxHelperMedia.AddNews(accessToken, articles); if (result.errcode == ReturnCode.请求成功) { responseBox.Text = result.errcode.ToString() + "\n"; responseBox.AppendText("media_id:" + result.media_id); } else { responseBox.Text = result.errcode.ToString() + "\n" + result.errmsg.ToString(); } }
private void button33_Click(object sender, EventArgs e) { //新增永久素材 if (openFileDialog1.FileName == "") { responseBox.Text = "请上传文件"; return; } MediaType type = (MediaType)Enum.Parse(typeof(MediaType), comboBox1.SelectedItem.ToString(), true); var result = WxHelperMedia.UploadPermanentMedia(accessToken, openFileDialog1.FileName, type); if (result.errcode == ReturnCode.请求成功) { responseBox.Text = result.errcode.ToString() + "\n"; responseBox.AppendText( "type:" + result.type.ToString() + "\n" + "media_id:" + result.media_id + "\n" + "created_at:" + DateTimeHelper.ConvertToDateTime(Convert.ToInt64(result.created_at)).ToLocalTime() + "\n" ); } else { responseBox.Text = result.errcode.ToString() + "\n" + result.errmsg.ToString(); } }