获取WeChatControllers中的Access_Token

  • A+
所属分类:微信开发

获取WeChatControllers中的Access_Token

Controllers

  1. HttpWebRequest myRequest =(HttpWebRequest)WebRequest.Create("Url");  
  2. myRequest.Method = "POST";  
  3. Stream newStream = myRequest.GetRequestStream();  
  4. newStream.Close();  
  5. HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();  
  6. StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);  
  7. string result = reader.ReadLine();//.ReadToEnd();  
  8. //解析json数据  
  9. JavaScriptSerializer js = new JavaScriptSerializer();  
  10. ResultJsonData list = js.Deserialize<ResultJsonData>(result);  
  11. string resultM = list.access_token;  
  12.   
  13. public class ResultJsonData  
  14. {  
  15.     public string access_token { getset; }  
  16.     public string token_type { getset; }  
  17.     public int expires_in { getset; }  
  18.     public string refresh_token { getset; }  
  19. }  
钰玺

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: