public IEnumerator CreatePrivateLeaderboard(string table, bool highest, string permalink) { var postdata = new Dictionary <String, String>(); postdata.Add("table", table); postdata.Add("highest", highest ? "y" : "n"); postdata.Add("permalink", permalink); string url; WWWForm post; Playtomic_Request.Prepare(SECTION, CREATEPRIVATELEADERBOARD, postdata, out url, out post); WWW www = new WWW(url, post); yield return(www); var response = Playtomic_Request.Process(www); if (response.Success) { var data = (Hashtable)response.JSON; foreach (string key in data.Keys) { var name = WWW.UnEscapeURL(key); var value = WWW.UnEscapeURL((string)data[key]); response.Data.Add(name, value); } } SetResponse(response, "CreatePrivateLeaderboard"); }
public IEnumerator LoadPrivateLeaderboard(string tableid) { var postdata = new Dictionary <String, String>(); postdata.Add("tableid", tableid); string url; WWWForm post; Playtomic_Request.Prepare(SECTION, LOADPRIVATELEADERBOARD, postdata, out url, out post); WWW www = new WWW(url, post); yield return(www); var response = Playtomic_Request.Process(www); if (response.Success) { var data = (Hashtable)response.JSON; foreach (string key in data.Keys) { var name = WWW.UnEscapeURL(key); var value = WWW.UnEscapeURL((string)data[key]); response.Data.Add(name, value); } } SetResponse(response, "LoadPrivateLeaderboard"); }
public IEnumerator Load() { string url; WWWForm post; Playtomic_Request.Prepare(SECTION, LOAD, null, out url, out post); WWW www = new WWW(url, post); yield return(www); var response = Playtomic_Request.Process(www); if (response.Success) { var data = (Hashtable)response.JSON; foreach (string key in data.Keys) { var name = WWW.UnEscapeURL(key); var value = WWW.UnEscapeURL((string)data[key]); response.Data.Add(name, value); } } SetResponse(response, "Load"); }
public IEnumerator Rate(string levelid, int rating) { if (rating < 1 || rating > 10) { SetResponse(Playtomic_Response.Error(401), "Rate"); yield break; } var postdata = new Dictionary <String, String>(); postdata.Add("levelid", levelid); postdata.Add("rating", rating.ToString()); string url; WWWForm post; Playtomic_Request.Prepare(SECTION, RATE, postdata, out url, out post); WWW www = new WWW(url, post); yield return(www); var response = Playtomic_Request.Process(www); SetResponse(response, "Rate"); }
private IEnumerator GetData(string type, string action, Dictionary <String, String> postdata) { string url; WWWForm post; Playtomic_Request.Prepare(SECTION, action, postdata, out url, out post); WWW www = new WWW(url, post); yield return(www); Debug.Log(www.text); var response = Playtomic_Request.Process(www); if (response.Success) { var data = (Hashtable)response.JSON; foreach (string key in data.Keys) { var name = WWW.UnEscapeURL(key); var value = WWW.UnEscapeURL((string)data[key]); response.Data.Add(name, value); } } SetResponse(response, type); }
public IEnumerator Load(string pobjectid, string classname) { var pobject = new PFObject(); pobject.ObjectId = pobjectid; pobject.ClassName = classname; string url; WWWForm post; Playtomic_Request.Prepare(SECTION, LOAD, ObjectPostData(pobject), out url, out post); WWW www = new WWW(url, post); yield return(www); var response = Playtomic_Request.Process(www); if (response.Success) { var data = response.JSON; var po = new PFObject(); po.ClassName = (string)data["classname"]; po.ObjectId = (string)data["id"]; po.Password = (string)data["password"]; po.CreatedAt = DateTime.Parse((string)data["created"]); po.UpdatedAt = DateTime.Parse((string)data["updated"]); var fields = (Hashtable)data["fields"]; foreach (var key in fields.Keys) { po.Data.Add((string)key, (string)fields[key]); } var pointers = (Hashtable)data["pointers"]; foreach (var key in pointers.Keys) { var pdata = (ArrayList)pointers[key]; var pchild = new PFObject(); pchild.ObjectId = (string)pdata[0]; pchild.ClassName = (string)pdata[1]; po.Pointers.Add(new PFPointer((string)key, pchild)); } response.PObject = po; } SetResponse(response, "Load"); }
public IEnumerator Load(string levelid) { var postdata = new Dictionary <String, String>(); postdata.Add("levelid", levelid); string url; WWWForm post; Playtomic_Request.Prepare(SECTION, LOAD, postdata, out url, out post); WWW www = new WWW(url, post); yield return(www); var response = Playtomic_Request.Process(www); if (response.Success) { var item = response.JSON; var level = new Playtomic_PlayerLevel(); level.LevelId = (string)item["LevelId"]; level.PlayerSource = (string)item["PlayerSource"]; level.PlayerName = WWW.UnEscapeURL((string)item["PlayerName"]); level.Name = WWW.UnEscapeURL((string)item["Name"]); level.Votes = (int)(double)item["Votes"]; level.Plays = (int)(double)item["Plays"]; level.Rating = (double)item["Rating"]; level.Score = (int)(double)item["Score"]; level.SDate = DateTime.Parse((string)item["SDate"]); level.RDate = WWW.UnEscapeURL((string)item["RDate"]); if (item.ContainsKey("Data")) { level.Data = (string)item["Data"]; } if (item.ContainsKey("CustomData")) { Hashtable customdata = (Hashtable)item["CustomData"]; foreach (var key in customdata.Keys) { level.CustomData.Add((string)key, WWW.UnEscapeURL((string)customdata[key])); } } response.Levels = new List <Playtomic_PlayerLevel>(); response.Levels.Add(level); } SetResponse(response, "Load"); }
public IEnumerator Delete(PFObject pobject) { string url; WWWForm post; Playtomic_Request.Prepare(SECTION, DELETE, ObjectPostData(pobject), out url, out post); WWW www = new WWW(url, post); yield return(www); var response = Playtomic_Request.Process(www); SetResponse(response, "Delete"); }
public IEnumerator Save(Playtomic_PlayerLevel level) { var postdata = new Dictionary <String, String>(); postdata.Add("data", level.Data); postdata.Add("playerid", level.PlayerId); postdata.Add("playername", level.PlayerName); postdata.Add("playersource", Playtomic.SourceUrl); postdata.Add("name", level.Name); postdata.Add("nothumb", "y"); postdata.Add("customfields", level.CustomData.Count.ToString()); var n = 0; foreach (var key in level.CustomData.Keys) { postdata.Add("ckey" + n, key); postdata.Add("cdata" + n, level.CustomData[key]); n++; } string url; WWWForm post; Playtomic_Request.Prepare(SECTION, SAVE, postdata, out url, out post); WWW www = new WWW(url, post); yield return(www); var response = Playtomic_Request.Process(www); if (response.Success) { var data = (Hashtable)response.JSON; foreach (string key in data.Keys) { var name = WWW.UnEscapeURL(key); var value = WWW.UnEscapeURL((string)data[key]); response.Data.Add(name, value); } } SetResponse(response, "Save"); }
public IEnumerator Save(string table, Playtomic_PlayerScore score, bool highest, bool allowduplicates, bool facebook) { var postdata = new Dictionary <String, String>(); postdata.Add("table", table); postdata.Add("highest", highest ? "y" : "n"); postdata.Add("name", score.Name); postdata.Add("points", score.Points.ToString()); postdata.Add("allowduplicates", allowduplicates ? "y" : "n"); postdata.Add("auth", Playtomic_Encode.MD5(Playtomic.SourceUrl + score.Points)); postdata.Add("customfields", score.CustomData.Count.ToString()); postdata.Add("fbuserid", string.IsNullOrEmpty(score.FBUserId) ? "" : score.FBUserId); postdata.Add("fb", facebook ? "y" : "n"); postdata.Add("url", Playtomic.SourceUrl); var n = 0; foreach (var key in score.CustomData.Keys) { postdata.Add("ckey" + n, key); postdata.Add("cdata" + n, score.CustomData[key]); n++; } string url; WWWForm post; Playtomic_Request.Prepare(SECTION, SAVE, postdata, out url, out post); WWW www = new WWW(url, post); yield return(www); var response = Playtomic_Request.Process(www); SetResponse(response, "Save"); }
public IEnumerator Save(PFObject pobject) { string url; WWWForm post; Playtomic_Request.Prepare(SECTION, SAVE, ObjectPostData(pobject), out url, out post); WWW www = new WWW(url, post); yield return(www); var response = Playtomic_Request.Process(www); if (response.Success) { var data = (Hashtable)response.JSON; pobject.ObjectId = (string)data["id"]; pobject.CreatedAt = DateTime.Parse((string)data["created"]); pobject.UpdatedAt = DateTime.Parse((string)data["updated"]); response.PObject = pobject; } SetResponse(response, "Save"); }
public IEnumerator List(string table, bool highest, string mode, int page, int perpage, bool facebook, Dictionary <String, String> customfilters, string[] friendslist) { var numfilters = customfilters == null ? 0 : customfilters.Count; var postdata = new Dictionary <String, String>(); postdata.Add("table", table); postdata.Add("highest", highest ? "y" : "n"); postdata.Add("mode", mode); postdata.Add("page", page.ToString()); postdata.Add("perpage", perpage.ToString()); postdata.Add("filters", numfilters.ToString()); postdata.Add("url", "global"); if (numfilters > 0) { var fieldnumber = 0; foreach (var key in customfilters.Keys) { postdata.Add("ckey" + fieldnumber, key); postdata.Add("cdata" + fieldnumber, customfilters[key]); fieldnumber++; } } if (facebook) { postdata.Add("fb", "y"); if (friendslist != null && friendslist.Length > 0) { postdata.Add("friendslist", string.Join(",", friendslist)); } } else { postdata.Add("fb", "n"); } string url; WWWForm post; Playtomic_Request.Prepare(SECTION, LIST, postdata, out url, out post); WWW www = new WWW(url, post); yield return(www); var response = Playtomic_Request.Process(www); if (response.Success) { var data = (Hashtable)response.JSON; var scores = (ArrayList)data["Scores"]; var len = scores.Count; response.NumItems = (int)(double)data["NumScores"]; response.Scores = new List <Playtomic_PlayerScore>(); for (var i = 0; i < len; i++) { Hashtable item = (Hashtable)scores[i]; var sscore = new Playtomic_PlayerScore(); sscore.Name = WWW.UnEscapeURL((string)item["Name"]); sscore.Points = (int)(double)item["Points"]; sscore.SDate = DateTime.Parse((string)item["SDate"]); sscore.RDate = WWW.UnEscapeURL((string)item["RDate"]); sscore.Rank = (long)(double)item["Rank"]; if (item.ContainsKey("CustomData")) { Hashtable customdata = (Hashtable)item["CustomData"]; foreach (var key in customdata.Keys) { sscore.CustomData.Add((string)key, WWW.UnEscapeURL((string)customdata[key])); } } response.Scores.Add(sscore); } } SetResponse(response, "List"); }
public IEnumerator SaveAndList(string table, Playtomic_PlayerScore score, bool highest, string mode, int perpage, bool isglobal, bool allowduplicates, bool facebook, Dictionary <String, String> customfilters) { var postdata = new Dictionary <String, String>(); // common data postdata.Add("table", table); postdata.Add("highest", highest ? "y" : "n"); postdata.Add("fb", facebook ? "y" : "n"); // save data postdata.Add("name", score.Name); postdata.Add("points", score.Points.ToString()); postdata.Add("allowduplicates", allowduplicates ? "y" : "n"); postdata.Add("auth", Playtomic_Encode.MD5(Playtomic.SourceUrl + score.Points)); postdata.Add("numfields", score.CustomData.Count.ToString()); postdata.Add("fbuserid", string.IsNullOrEmpty(score.FBUserId) ? "" : score.FBUserId); postdata.Add("url", Playtomic.SourceUrl); var n = 0; foreach (var key in score.CustomData.Keys) { postdata.Add("ckey" + n, key); postdata.Add("cdata" + n, score.CustomData[key]); n++; } // list data var numfilters = customfilters == null ? 0 : customfilters.Count; postdata.Add("global", isglobal ? "y" : "n"); postdata.Add("perpage", perpage.ToString()); postdata.Add("mode", mode); postdata.Add("numfilters", numfilters.ToString()); var fieldnumber = 0; if (numfilters > 0) { foreach (var key in customfilters.Keys) { postdata.Add("lkey" + fieldnumber, key); postdata.Add("ldata" + fieldnumber, customfilters[key]); fieldnumber++; } } string url; WWWForm post; Playtomic_Request.Prepare(SECTION, SAVEANDLIST, postdata, out url, out post); WWW www = new WWW(url, post); yield return(www); var response = Playtomic_Request.Process(www); if (response.Success) { var data = (Hashtable)response.JSON; var scores = (ArrayList)data["Scores"]; var len = scores.Count; response.NumItems = (int)(double)data["NumScores"]; response.Scores = new List <Playtomic_PlayerScore>(); for (var i = 0; i < len; i++) { Hashtable item = (Hashtable)scores[i]; var sscore = new Playtomic_PlayerScore(); sscore.Name = WWW.UnEscapeURL((string)item["Name"]); sscore.Points = (int)(double)item["Points"]; sscore.SDate = DateTime.Parse((string)item["SDate"]); sscore.RDate = WWW.UnEscapeURL((string)item["RDate"]); sscore.Rank = (long)(double)item["Rank"]; if (item.ContainsKey("SubmittedOrBest")) { sscore.SubmittedOrBest = item["SubmittedOrBest"].ToString() == "true"; } if (item.ContainsKey("CustomData")) { Hashtable customdata = (Hashtable)item["CustomData"]; foreach (var key in customdata.Keys) { sscore.CustomData.Add((string)key, WWW.UnEscapeURL((string)customdata[key])); } } response.Scores.Add(sscore); } } SetResponse(response, "SaveAndList"); }
public IEnumerator Find(PFQuery pquery) { var postdata = new Dictionary <String, String>(); postdata.Add("classname", pquery.ClassName); postdata.Add("limit", pquery.Limit.ToString()); postdata.Add("order", !string.IsNullOrEmpty(pquery.Order) ? pquery.Order : "created_at"); foreach (var key in pquery.WhereData.Keys) { postdata.Add("data" + key, pquery.WhereData[key]); } for (var i = pquery.WherePointers.Count - 1; i > -1; i--) { postdata["pointer" + i + "fieldname"] = pquery.WherePointers[i].FieldName; postdata["pointer" + i + "classname"] = pquery.WherePointers[i].PObject.ClassName; postdata["pointer" + i + "id"] = pquery.WherePointers[i].PObject.ObjectId; } string url; WWWForm post; Playtomic_Request.Prepare(SECTION, FIND, postdata, out url, out post); WWW www = new WWW(url, post); yield return(www); var response = Playtomic_Request.Process(www); if (response.Success) { response.PObjects = new List <PFObject>(); var array = response.ARRAY; foreach (Hashtable data in array) { var po = new PFObject(); po.ClassName = (string)data["classname"]; po.ObjectId = (string)data["id"]; po.Password = (string)data["password"]; po.CreatedAt = DateTime.Parse((string)data["created"]); po.UpdatedAt = DateTime.Parse((string)data["updated"]); var fields = (Hashtable)data["fields"]; foreach (var key in fields.Keys) { po.Data.Add((string)key, (string)fields[key]); } var pointers = (Hashtable)data["pointers"]; foreach (var key in pointers.Keys) { var pdata = (ArrayList)pointers[key]; var pchild = new PFObject(); pchild.ObjectId = (string)pdata[0]; pchild.ClassName = (string)pdata[1]; po.Pointers.Add(new PFPointer((string)key, pchild)); } response.PObjects.Add(po); } } SetResponse(response, "Find"); }
public IEnumerator List(string mode, int page, int perpage, bool includedata, bool includethumbs, DateTime datemin, DateTime datemax) { var postdata = new Dictionary <String, String>(); postdata.Add("mode", mode); postdata.Add("page", page.ToString()); postdata.Add("perpage", perpage.ToString()); postdata.Add("thumbs", includethumbs ? "y" : "n"); postdata.Add("data", includedata ? "y" : "n"); postdata.Add("datemin", datemin.ToString("MM/dd/yyyy")); postdata.Add("datemax", datemax.ToString("MM/dd/yyyy")); /*var n = 0; * * foreach(var key in level.CustomData.Keys) * { * postdata.Add("ckey" + n, key); * postdata.Add("cdata" + n, level.CustomData[key]); * n++; * }*/ postdata.Add("filters", "0"); string url; WWWForm post; Playtomic_Request.Prepare(SECTION, LIST, postdata, out url, out post); WWW www = new WWW(url, post); yield return(www); var response = Playtomic_Request.Process(www); if (response.Success) { var data = (Hashtable)response.JSON; var levels = (ArrayList)data["Levels"]; var len = levels.Count; response.NumItems = (int)(double)data["NumLevels"]; response.Levels = new List <Playtomic_PlayerLevel>(); for (var i = 0; i < len; i++) { Hashtable item = (Hashtable)levels[i]; var level = new Playtomic_PlayerLevel(); level.LevelId = (string)item["LevelId"]; level.PlayerSource = (string)item["PlayerSource"]; level.PlayerName = WWW.UnEscapeURL((string)item["PlayerName"]); level.Name = WWW.UnEscapeURL((string)item["Name"]); level.Votes = (int)(double)item["Votes"]; level.Plays = (int)(double)item["Plays"]; level.Rating = (double)item["Rating"]; level.Score = (int)(double)item["Score"]; level.SDate = DateTime.Parse((string)item["SDate"]); level.RDate = WWW.UnEscapeURL((string)item["RDate"]); if (item.ContainsKey("Data")) { level.Data = (string)item["Data"]; } if (item.ContainsKey("CustomData")) { Hashtable customdata = (Hashtable)item["CustomData"]; foreach (var key in customdata.Keys) { level.CustomData.Add((string)key, WWW.UnEscapeURL((string)customdata[key])); } } response.Levels.Add(level); } } SetResponse(response, "List"); }