IEnumerator sendscore(string name, int score, int lesson_id) { string SetUrl = "https://scivre.herokuapp.com/api/webscivreapisave"; if (Validation1.checkConnectionfail() == true) { Debug.Log("Error: Internet Connection"); } else { WWWForm form = new WWWForm(); form.AddField("name", name); form.AddField("score", score); form.AddField("lesson_id", lesson_id); Debug.Log(lesson_id); using (UnityWebRequest www = UnityWebRequest.Post(SetUrl, form)) { www.chunkedTransfer = false; yield return(www.SendWebRequest()); if (www.error != null) { Debug.Log("Error webserver request error: " + www.error); } else { Debug.Log("Response" + www.downloadHandler.text); Validation1.UserData userData = JsonUtility.FromJson <Validation1.UserData> (www.downloadHandler.text); } } } }
IEnumerator fetch(string name) { string SetUrl = "localhost:81/superweb/webscivre/public/api/webscivreapifetch"; if (Validation1.checkConnectionfail() == true) { Debug.Log("Error: Internet Connection"); } else { WWWForm form = new WWWForm(); form.AddField("name", name); using (UnityWebRequest www = UnityWebRequest.Post(SetUrl, form)) { yield return(www.SendWebRequest()); if (www.error != null) { Debug.Log("Error webserver request error: " + www.error); } else { Debug.Log("Response" + www.downloadHandler.text); Validation1.UserData userData = JsonUtility.FromJson <Validation1.UserData> (www.downloadHandler.text); //reponse details PlayerPrefs.SetString("id", userData.student_id.ToString()); } } } }
IEnumerator fetch(string lrn) { string SetUrl = "https://scivre.herokuapp.com/api/webapifetchname"; if (Validation1.checkConnectionfail() == true) { Debug.Log("Error: Internet Connection"); canvasLoad.SetActive(false); } else { WWWForm form = new WWWForm(); form.AddField("id", lrn); using (UnityWebRequest www = UnityWebRequest.Post(SetUrl, form)) { canvasLoad.SetActive(true); lblLoader.text = "Checking Credentials"; www.chunkedTransfer = false; yield return(www.SendWebRequest()); if (www.error != null) { Debug.Log("Error webserver request error: " + www.error); } else { Debug.Log("Response" + www.downloadHandler.text); Validation1.UserData userData = JsonUtility.FromJson <Validation1.UserData> (www.downloadHandler.text); //reponse detail accountname.text = "Account Name: " + userData.first_name + " " + userData.last_name; lblLoader.text = "Credentials Found!...."; yield return(new WaitForSeconds(3f)); checkPanel.SetActive(false); loginPanel.SetActive(false); changePanel.SetActive(true); canvasLoad.SetActive(false); } } } }
IEnumerator fetch(string uname) { string SetUrl = "https://scivre.herokuapp.com/api/webscivreapifetch"; if (Validation1.checkConnectionfail() == true) { Debug.Log("Error: Internet Connection"); canvasLoad.SetActive(false); } else { WWWForm form = new WWWForm(); form.AddField("name", uname); using (UnityWebRequest www = UnityWebRequest.Post(SetUrl, form)) { www.chunkedTransfer = false; yield return(www.SendWebRequest()); if (www.error != null) { Debug.Log("Error webserver request error: " + www.error); } else { Debug.Log("Response" + www.downloadHandler.text); Validation1.UserData userData = JsonUtility.FromJson <Validation1.UserData> (www.downloadHandler.text); //reponse detail PlayerPrefs.SetString("id", userData.student_id.ToString("(12,0)")); PlayerPrefs.SetString("first_name", userData.first_name); PlayerPrefs.SetString("middle_name", userData.middle_name); PlayerPrefs.SetString("last_name", userData.last_name); PlayerPrefs.SetString("name", userData.name); PlayerPrefs.SetInt("isLogged", 1); } } } }