IEnumerator RedeemIt(string QType) { yield return(new WaitForSeconds(0.3f)); var url = "http://139.59.100.192/PH/ClaimMission"; var form = new WWWForm(); form.AddField("ID", EventID); form.AddField("PID", PlayerPrefs.GetString(Link.ID)); form.AddField("QType", QType); form.AddField("DID", PlayerPrefs.GetString(Link.DEVICE_ID)); WWW www = new WWW(url, form); yield return(www); Debug.Log(www.text); if (www.error == null) { var jsonString = JSON.Parse(www.text); //Debug.Log(jsonString["data"][0]["QS1"]); int ResCode = int.Parse(jsonString["code"]); switch (ResCode) { case 9: print("pop up already sent it"); RedeemCodeHandle.SetActive(true); RedeemCodeHandle.transform.FindChild("Text").GetComponent <Text> ().text = "Event Expired,\n Please Close this page."; break; case 8: print("pop up expired event"); RedeemCodeHandle.SetActive(true); RedeemCodeHandle.transform.FindChild("Text").GetComponent <Text> ().text = "Event Expired,\n Please Close this page."; break; case 77: print("Whadya want?"); RedeemCodeHandle.SetActive(true); RedeemCodeHandle.transform.FindChild("Text").GetComponent <Text> ().text = "Already Taken,\n wait till tommorrow."; StartCoroutine(LoadNewsDetail()); break; case 6: print("nothing to see yet"); break; case 1: RedeemCodeHandle.SetActive(true); RedeemCodeHandle.transform.FindChild("Text").GetComponent <Text> ().text = "Done,\n Check your inbox."; StartCoroutine(LoadNewsDetail()); print("check inbox"); break; default: break; } } }
private IEnumerator RedeemCode() { string url = Link.url + "RedeemPlayerCode"; WWWForm form = new WWWForm(); form.AddField("PID", PlayerPrefs.GetString(Link.ID)); form.AddField("Code", RedeemCodeIF.text); WWW www = new WWW(url, form); yield return(www); if (www.error == null) { print(www.text); var jsonString = JSON.Parse(www.text); Debug.Log(jsonString); if (int.Parse(jsonString["code"]) == 1) { RedeemCodeHandle.SetActive(true); RedeemCodeHandle.transform.FindChild("Text").GetComponent <Text> ().text = "Redeem code success,\n Check your inbox."; RedeemCodeIF.text = ""; } else if (int.Parse(jsonString["code"]) == 22) { RedeemCodeHandle.SetActive(true); RedeemCodeHandle.transform.FindChild("Text").GetComponent <Text> ().text = "Check the code."; } else { RedeemCodeHandle.SetActive(true); RedeemCodeHandle.transform.FindChild("Text").GetComponent <Text> ().text = " The code already redeemed by this user"; RedeemCodeIF.text = ""; } errorhandle.SetActive(false); } else { print(www.text); print("fafal niam"); errorhandle.SetActive(true); errorhandle.transform.FindChild("Dialog").gameObject.SetActive(true); } }