using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RequestManager : MonoBehaviour {
public static string apiGET(string path, Dictionary<string,string> parameters) {
string result = "";
if (parameters.Count > 0) {
foreach (string key in parameters.Keys) {
result = string.Concat(string.Concat("&", key), parameters[key].ToString());
}
result = result.Substring(1);
}
string url = GlobalsParams.API_URL+""+path;
if(result != "") {
url = url + "?" + result;
}
WWW req = new WWW(url);
float elapsedTime = 0.0f;
while (!req.isDone)
{
elapsedTime += Time.deltaTime;
if (elapsedTime >= 10.0f) break;
}
if (!req.isDone || !string.IsNullOrEmpty(req.error)) {
Debug.Log("Load Failed");
return "Load Failed";
} else {
Debug.Log(req.text);
return req.text;
}
}
}