获取微信企业号media_id
Posted IT飞牛
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了获取微信企业号media_id相关的知识,希望对你有一定的参考价值。
protected void Button1_Click(object sender, EventArgs e)
if (File1.PostedFile.ContentLength != 0)
//获取 ACCESS_TOKEN
string accessjson = pub.Weixin.GetAccessToken();
M.accessstring access_model = pub.json.JsonDeserializeBySingleData<M.accessstring>(accessjson);
string ACCESS_TOKEN = access_model.access_token; //获取ACCESS_TOKEN
string type = "image";
//发送请求url
string sUrl = "https://qyapi.weixin.qq.com/cgi-bin/material/add_material?type="+ type + "&access_token=" + ACCESS_TOKEN;
if (File1.PostedFile.ContentLength!=0)
string filename = File1.PostedFile.FileName;
string path = Server.MapPath("./");
path += filename;
if (File.Exists(path))
Response.Write("文件已经存在");
return;
File1.PostedFile.SaveAs(path);
WebClient myWebClient = new WebClient();
myWebClient.Credentials = CredentialCache.DefaultCredentials;
try
//上传数据获得字符
byte[] responseArray = myWebClient.UploadFile(sUrl,"POST",path);
//转换字符
string ret = System.Text.Encoding.Default.GetString(responseArray,0,responseArray.Length);
//解析json
M.material mymaterial = pub.json.JsonDeserializeBySingleData<M.material>(ret);
Response.Write(mymaterial.media_id);
catch(Exception ex)
参考网址:
http://bbs.csdn.net/topics/391014694/
以上是关于获取微信企业号media_id的主要内容,如果未能解决你的问题,请参考以下文章