Unity 获取web数据
WebClient client = new WebClient();
var address = "http://api.xianyuqp.cn/UserPlayRecord.ashx?userid=1&kindid=300"
string historyData = client.DownloadString(address);
unity 下载web资源
-
- public void OperDownloadFile(string Url)
- {
- WebClient _client = new WebClient();
- //下载之后的文件名字
- string Path = Server.MapPath("1.mp3");
- _client.DownloadFile(Url, Path);
- }
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);