Unity 获取web数据

Unity 获取web数据

 WebClient client = new WebClient();

  client.Encoding = Encoding.UTF8;
  var address = "http://api.xianyuqp.cn/UserPlayRecord.ashx?userid=1&kindid=300"

  string historyData = client.DownloadString(address);

unity 下载web资源


  1.         public void OperDownloadFile(string Url)  
  2.         {  
  3.             WebClient _client = new WebClient();  
  4.   
  5.             //下载之后的文件名字  
  6.             string Path = Server.MapPath("1.mp3");  
  7.   
  8.             _client.DownloadFile(Url, Path);  
  9.         }  

Unity 发送信息给web

System.Collections.Specialized.NameValueCollection myPostPara = new System.Collections.Specialized.NameValueCollection();
            myPostPara.Add("userid", GlobalMyUserInfo.dwUserID.ToString());           
            myPostPara.Add("title", title);
            myPostPara.Add("content", textFeedback);

            WebClient client = new WebClient();
            byte[] byWebContent = client.UploadValues("http://api.baidu.cn/xxxxx.ashx", "POST", myPostPara);



猜你喜欢

转载自blog.csdn.net/m0_37583098/article/details/76855229