企業微信圖片上傳介面:https://qyapi.weixin.qq.com/cgi-bin/media/uploadimg?access_token=ACCESS_TOKEN
請求示例:
---------------------------acebdf13572468
Content-Disposition: form-data; name="fieldNameHere"; filename="20180103195745.png"
Content-Type: image/png
Content-Length: 220
<@INCLUDE *C:\Users\abelzhu\Pictures\企業微信截圖_20180103195745.png*@>
---------------------------acebdf13572468--
新手請前輩幫忙看一下這個用C#代碼怎么實作? 我本地的圖片一定需要上傳到我的服務器端、再呼叫這個介面上傳嗎?
下面是我呼叫其他介面的方法:
public string GETWXInter(object obj,string url) //Obj是傳入的引數,url是呼叫的介面地址(含TOKEN)
{
string result = string.Empty;
string m_QuestURL = url;//請求地址
Encoding encoding = Encoding.GetEncoding("utf-8");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(m_QuestURL);
request.Method = "post";
request.ContentType = "application/json";
request.Accept = "application/xml";
if (obj != null)
{
string requestXml = JsonConvert.SerializeObject(obj);
byte[] buffer = encoding.GetBytes(requestXml);
request.ContentLength = buffer.Length;
request.GetRequestStream().Write(buffer, 0, buffer.Length);
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.GetEncoding("utf-8")))
{
result = reader.ReadToEnd();
}
return result;
}
麻煩高手給寫一個上面這樣的方法,可以上傳圖片并回傳圖片的URL,感謝!
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/14612.html
標籤:C#
上一篇:關于能峰的問題,怎么通過代碼自動識別后面的能峰?我要將第二個峰進行擬合,找不到合適的閾值能讓代碼自動識別這個峰
下一篇:計算一個公式,希望各位幫幫忙,要求計算出C1,C2,C3。只要列出每一步的計算程序就可以,如果能舉出具體的例子更好 假如已知: η= 3000,t = 0.0
