unity 里的get和post方法调用
Posted Fei非非
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了unity 里的get和post方法调用相关的知识,希望对你有一定的参考价值。
(一)GET方法
IEnumerator SendGet(string _url) { WWW getData = new WWW(_url); yield return getData; if(getData.error != null) { Debug.Log(getData.error); } else { Debug.Log(getData.text); } }
(二)POST方法
IEnumerator SendPost(string _url, WWWForm _wForm) { WWW postData = new WWW(_url, _wForm); yield return postData; if (postData.error != null) { Debug.Log(postData.error); } else { Debug.Log(postData.text); } }
调用两个方法
public void TestHttpSend() { //测试GET方法 StartCoroutine(SendGet("http://kun.show.ghostry.cn/?int=5")); //测试POST方法 WWWForm form = new WWWForm(); form.AddField("int", "6"); StartCoroutine(SendPost("http://kun.show.ghostry.cn/", form)); }
以上是关于unity 里的get和post方法调用的主要内容,如果未能解决你的问题,请参考以下文章
jsp调用servlet时get方法和post方法有啥区别?
WWW / UnityWebRequest POST / GET请求不会从server / url返回最新数据