IEnumerator GetExpositions(OnResponseCallback response = null) { string uri = URL_API + url_exposition_api + "getExpositions.php"; string message = ""; using (UnityWebRequest webRequest = UnityWebRequest.Get(uri)) { // Request and wait for the desired page. yield return(webRequest.SendWebRequest()); if (webRequest.responseCode < 400) { message = ""; } else if (webRequest.responseCode >= 400 && webRequest.responseCode < 500) { message = "Charlas no encontradas"; } if (webRequest.isNetworkError) { Debug.Log(": Error: " + webRequest.error); if (response != null) { response(false, message); } } else { FillConferenceData(webRequest.downloadHandler.text, response); } } }
private void FillConferenceData(string data, OnResponseCallback response = null) { var n = JSON.Parse(data); //Debug.Log(n); List <Exposition> arrExpo = new List <Exposition>(); for (int i = 0; i < n["message"].Count; i++) { Exposition e = new Exposition(); e.id = n["message"][i]["id"].AsInt; e.date = DateTime.Parse(n["message"][i]["date"].Value); e.name_exposition = n["message"][i]["name_exposition"].Value; e.info_exposition = n["message"][i]["info_exposition"].Value; e.hour = n["message"][i]["hour"].Value; e.room = n["message"][i]["room"].Value; e.name_expositor = n["message"][i]["name_expositor"].Value; e.url_photo_expositor = n["message"][i]["photo_expositor"].Value; e.info_expositor = n["message"][i]["info_expositor"].Value; arrExpo.Add(e); } ConferenceControl.Instance.FillExpositionsInformation(arrExpo); if (response != null) { response(true, "Datos cargado correctamente"); } }
public void addLike(int idExpo, OnResponseCallback response = null) { WWWForm form = new WWWForm(); form.AddField("user_id", AppManager.Instance.currUser.id); form.AddField("expo_id", idExpo); string url = URL_API + url_user_api + "addLike.php"; StartCoroutine(PostLibrary(form, url, response)); }
IEnumerator Register(string email, OnResponseCallback response = null) { WWWForm form = new WWWForm(); form.AddField("email", email); string url = URL_API + url_user_api + "register.php"; using (UnityWebRequest www = UnityWebRequest.Post(url, form)) { yield return(www.SendWebRequest()); string message = ""; if (www.responseCode < 400) { message = ""; } else if (www.responseCode >= 400 && www.responseCode < 500) { message = "El usuario ingresado ya existe"; } else { message = "Problemas en el servidor. Intente nuevamente"; } if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); if (response != null) { response(false, message); } } else { //Debug.Log(www.downloadHandler.text); FillUserData(www.downloadHandler.text); if (response != null) { response(true, message); } } } }
IEnumerator GetUser(string email, OnResponseCallback response = null) { string uri = URL_API + url_user_api + "getUser.php?email=" + email; string message = ""; using (UnityWebRequest webRequest = UnityWebRequest.Get(uri)) { // Request and wait for the desired page. yield return(webRequest.SendWebRequest()); if (webRequest.responseCode < 400) { message = ""; } else if (webRequest.responseCode >= 400 && webRequest.responseCode < 500) { message = "El usuario no existe"; } if (webRequest.isNetworkError) { Debug.Log(": Error: " + webRequest.error); if (response != null) { response(false, message); } } else { //Debug.Log(":\nReceived: " + webRequest.downloadHandler.text); FillUserData(webRequest.downloadHandler.text); if (response != null) { response(true, message); } } } }
IEnumerator PostLibrary(WWWForm form, string url, OnResponseCallback response = null) { using (UnityWebRequest www = UnityWebRequest.Post(url, form)) { yield return(www.SendWebRequest()); string message = ""; if (www.responseCode < 400) { message = ""; } else if (www.responseCode >= 400 && www.responseCode < 500) { message = "El usuario ingresado ya existe"; } else { message = "Problemas en el servidor. Intente nuevamente"; } if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); if (response != null) { response(false, message); } } else { if (response != null) { response(true, message); } } } }
public void registerUser(string email, OnResponseCallback response = null) { StartCoroutine(Register(email, response)); }
public void getConferenceData(OnResponseCallback response = null) { StartCoroutine(GetExpositions(response)); }
public void getUserData(string email, OnResponseCallback response = null) { StartCoroutine(GetUser(email, response)); }