Home > Net >  Novice consult enterprise WeChat how to upload pictures interface implementation
Novice consult enterprise WeChat how to upload pictures interface implementation

Time:11-08

Enterprise WeChat picture upload interface: https://qyapi.weixin.qq.com/cgi-bin/media/uploadimg? Access_token=access_token

Sample request:
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- acebdf13572468
The Content - Disposition: the form - data; Name="fieldNameHere"; Filename="20180103195745 PNG"
The content-type: image/PNG
The Content - Length: 220

<@ INCLUDE * C: \ Users \ abelzhu, Pictures and company WeChat screenshots _20180103195745. PNG * @ & gt;
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- acebdf13572468 -

Novice predecessors, please help have a look at how the code in c #? I need local image must be uploaded to my server, call this interface to upload again?

Below is I call other interface methods:
Public string GETWXInter (object obj, string url)//obj is the incoming parameters, the url is the address of the interface call (TOKEN)
{
The string result=string. The Empty;
String m_QuestURL=url;//request address
Encoding Encoding=Encoding. GetEncoding (" utf-8 ");
HttpWebRequest request=(HttpWebRequest) WebRequest. Create (m_QuestURL);
Request. The 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. The method GetResponse ();
Using (StreamReader reader=new StreamReader (response. GetResponseStream (), System. Text. The Encoding. GetEncoding (" utf-8 ")))
{
Result=reader. ReadToEnd ();
}
return result;
}

Master of trouble to write a above this way, you can upload pictures and returns the URL of the picture, thanks!
  •  Tags:  
  • C#
  • Related