5.31从内网请求数据

usingUnityEngine;

usingSystem.Collections;

usingUnityEngine.Networking;

usingSystem.Collections.Generic;

publicclassPostStr:MonoBehaviour{

//http://192.168.10.10:8080/users

string url="http://192.168.10.10:8080/users";

//username=zhangsan  pwd=123456

voidStart( ){

StartCoroutine("Post_Login");

}

voidUpdate( ){

}

IEnumeratorPost_Login( ){

//1.

//List<IMultipartFormSection>formData=newList<IMultipartFormSection>( );

//formData.Add(new MultipartFormDataSection("username","zhangsan"));

//formData.Add(new MultipartFormDataSection("psd","123456"));

//formData.Add(new MultipartFormDataSection("username=zhangsan","psd==123456"));

//2.

//WWWForm form=new  WWWForm();//要传给服务器的参数

//form.AddField("username","zhangsan");

//form.AddField("pwd","123456");

//form.AddBinaryData( );//上传图片给服务器

//WWWwww=newWWW(url,form);

//3.

Dictionary<string,string>dic=new Dictionary<string,string>( );

dic.Add("username","zhangsan");

dic.Add("pwd","123456");

UnityWebRequest wr=UnityWebRequest.Post(url,dic);

wr.downloadHandler=new DownloadHandlerBuffer();

yield return wr.Send();

//UnityWebRequestwr=UnityWebRequest.Post(url,form);

//wr.downloadHandler=newDownloadHandlerBuffer();

//yieldreturnwr.Send();

if(!wr.isError){

print(wr.downloadHandler.text);

}

}

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容