C# unity3D get post

来源:互联网 发布:linux swap 释放 编辑:程序博客网 时间:2024/06/05 18:32

C#  IEnumerator     搜索 

yield return

//测试GET方法  
StartCoroutine(SendGet("http://postman-echo.com/time/now")); 
 //测试POST方法  
        var form = new WWWForm();  
        form.AddField("int", "6");  
        StartCoroutine(SendPost("http://kun.show.ghostry.cn/", form));     

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);  
         }  
    } 
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);  
        }  
    } 



0 0