unity3d BestHTTP
unity3d BestHTTP
#region /// <summary> /// 调用http接口 /// </summary> private void StartRequestData() {// BestHttp插件, 首先实例化一个HTTPRequest, 设置为Post形式, 并配置回调函数RequestHandle HTTPRequest request = new HTTPRequest(new Uri("http://localhost:8080/poor/search1"), HTTPMethods.Post, OnRequestComplete2); request.SetHeader("Content-Type", "application/json"); request.Send(); } #endregion #region /// <summary> /// 响应函数 /// </summary> /// <param name="request"></param> /// <param name="response"></param> private void OnRequestComplete2(HTTPRequest request, HTTPResponse response) { // 处理响应数据 if (response.IsSuccess) { string result_str1 = Encoding.UTF8.GetString(response.Data); JsonData jsonDataObj = JsonMapper.ToObject(result_str1); //if (jsonDataObj != null) { string jsonDataStr = jsonDataObj.ToString(); Debug.Log(jsonDataStr); } } else { Debug.Log("Request failed: " + response.Message); } } #endregion
############################
QQ 3087438119