public static async Task <GameEndResponse> EndGame(string gameId, int score) { //salt - de86cc2bab8e407e85f67587b7511395 //game_end_221c5656cvf56rtf67gyr45545de67340/ try { string gid = gameId; string uid = AppInfo.AppUser.UserId; string hash = LogicHelper.CreateMD5(uid, "de86cc2bab8e407e85f67587b7511395"); List <string> prms = new List <string> { "?hash=" + hash, "&uid=" + uid, "&gid=" + gid, "&score=" + score }; HttpHelper helper = new HttpHelper(); string response = await helper.Get("game_end_221c5656cvf56rtf67gyr45545de67340/", prms); List <GameEndResponse> obj = JsonConvert.DeserializeObject <List <GameEndResponse> >(response); GameEndResponse result = obj.First(); return(result); } catch (Exception) { return(null); } }
public static async Task <GameStartResponse> StartGame(string gameId) { //salt - 13032c9256e73dde7v4fd1eaqw12158 //game_start_440593f67221c50b647de6734734674/ try { string uid = AppInfo.AppUser.UserId; string hash = LogicHelper.CreateMD5(uid, "13032c9256e73dde7v4fd1eaqw12158"); string gid = gameId; List <string> prms = new List <string> { "?hash=" + hash, "&uid=" + uid, "&gid=" + gid }; HttpHelper helper = new HttpHelper(); string response = await helper.Get("game_start_440593f67221c50b647de6734734674/", prms); List <GameStartResponse> obj = JsonConvert.DeserializeObject <List <GameStartResponse> >(response); GameStartResponse result = obj.First(); return(result); } catch (Exception ex) { GameStartResponse result = new GameStartResponse(); result.StatusCode = 123; return(result); } }
public void PushUserToken() //TODO: Learn how it works! { //salt - 112fffa02cad313d433d4114b39250d7 Guid guid = Guid.NewGuid(); string token = ""; string hash = LogicHelper.CreateMD5(token, "112fffa02cad313d433d4114b39250d7"); }
public static async Task <GameSetStarsStatus> SetStars(string gameId, int stars) { //salt - 413a53a91318ed910b2cd26a0f2687f0 //game_set_stars_94fc0c136ad7fd3dc652c618bda5801f/ try { string uid = AppInfo.AppUser.UserId; string gid = gameId; string hash = LogicHelper.CreateMD5(uid, "413a53a91318ed910b2cd26a0f2687f0"); List <string> prms = new List <string> { "?hash=" + hash, "&uid=" + uid, "&gid=" + gid, "&stars=" + stars.ToString() }; HttpHelper helper = new HttpHelper(); string response = await helper.Get("game_set_stars_94fc0c136ad7fd3dc652c618bda5801f/", prms); dynamic obj = JsonConvert.DeserializeObject(response); int status = obj.First["status"]; switch (status) { case 100: return(GameSetStarsStatus.Ok); case 101: return(GameSetStarsStatus.HashError); case 102: return(GameSetStarsStatus.NotPlayedOrNotStarted); case 105: return(GameSetStarsStatus.GameError); case 109: return(GameSetStarsStatus.UserError); default: return(GameSetStarsStatus.HashError); } } catch (Exception) { return(GameSetStarsStatus.OtherIssues); } }
public static async Task <UserForgotPasswordResponse> ForgotPassword(string email) { //salt - 2f57af38610488bc8c686b6fcc133fb2 //sendpassword_4ffa763746353648ced17fdecba6324f/ try { string hash = LogicHelper.CreateMD5(email, "2f57af38610488bc8c686b6fcc133fb2"); List <string> prms = new List <string> { "?hash=" + hash, "&email=" + email, "&app=json" }; HttpHelper helper = new HttpHelper(); string response = await helper.Get("sendpassword_4ffa763746353648ced17fdecba6324f/", prms); dynamic obj = JsonConvert.DeserializeObject(response); int status = obj["Respons"].First["status"]; UserForgotPasswordResponse result = new UserForgotPasswordResponse(); switch (status) { case 100: result.Status = UserForgotPasswordStatus.Ok; result.Response = obj["Respons"].First["respons"]; break; case 101: result.Status = UserForgotPasswordStatus.HashError; break; case 102: result.Status = UserForgotPasswordStatus.EmailError; result.Response = obj["Respons"].First["respons"]; break; } return(result); } catch (Exception) { return(null); } }
public static async Task <List <PlayerModel> > GetPlayersList(string lid, string uid, PlayerListType type) { try { //salt - dc3000b3719bae69a676536f6a25eac1 //playerlist_4ff48620c7048686919e4ca2837200d5/ string hash = LogicHelper.CreateMD5(uid, "dc3000b3719bae69a676536f6a25eac1"); string ltype = ""; switch (type) { case PlayerListType.InGame: ltype = "1"; break; case PlayerListType.InChallenge: ltype = "2"; break; case PlayerListType.FriendsForChallenges: ltype = "3"; break; } List <string> prms = new List <string> { "?hash=" + hash, "&uid=" + uid, "&lid=" + lid, "<ype=" + ltype }; HttpHelper helper = new HttpHelper(); string response = await helper.Get("playerlist_4ff48620c7048686919e4ca2837200d5/", prms); List <PlayerModel> result = JsonConvert.DeserializeObject <List <PlayerModel> >(response); return(result); } catch (Exception) { return(null); } }
public static async Task GetUserData(string userId) { //salt - 03f42642c97513dc478fb6e8b4e5c723 //userdata_56f454036a322113c4f1fab5f98ad79d/ try { string hash = LogicHelper.CreateMD5(userId, "03f42642c97513dc478fb6e8b4e5c723"); List <string> prms = new List <string> { "?hash=" + hash, "&uid=" + userId }; HttpHelper helper = new HttpHelper(); string response = await helper.Get("userdata_56f454036a322113c4f1fab5f98ad79d/", prms); dynamic obj = JsonConvert.DeserializeObject(response); UserModel result = new UserModel() { UserId = obj["Respons"].First["uid"], FbId = obj["Respons"].First["fbid"], Name = obj["Respons"].First["uname"], Email = obj["Respons"].First["email"], PhoneNumber = obj["Respons"].First["phone"], CountryCode = obj["Respons"].First["countrycode"], TotalPlayedPuzzles = obj["Respons"].First["total_played_puzzles"], TotalCreatedPuzzles = obj["Respons"].First["total_created_puzzles"], TotalScore = obj["Respons"].First["total_score"], TotalRating = obj["Respons"].First["total_rating"], }; //result.UserId = obj.First.First.First.First.First; AppInfo.AppUser = result; return; } catch (Exception ex) { return; } }
public static async Task <UserPhotoUploadResponse> UploadProfilePhoto(string uid, WriteableBitmap image) { //salt - a04f16bad1b64acfeb7fd4b84b217c91 //profilephoto_dbea40501e2ab81fa435e3b911d47f55/ string hash = LogicHelper.CreateMD5(uid, "a04f16bad1b64acfeb7fd4b84b217c91"); Dictionary <string, string> prms = new Dictionary <string, string> { { "Hash", hash }, { "Uid", uid } }; HttpHelper helper = new HttpHelper(); string response = await helper.PostImage("profilephoto_dbea40501e2ab81fa435e3b911d47f55/", prms, image); dynamic obj = JsonConvert.DeserializeObject(response); int status = obj.First["status"]; switch (status) { case 100: return(UserPhotoUploadResponse.Ok); case 101: return(UserPhotoUploadResponse.HashError); case 102: return(UserPhotoUploadResponse.UnknownError); case 103: return(UserPhotoUploadResponse.UnknownFile); default: return(UserPhotoUploadResponse.UnknownError); } }
/// <summary> /// /// </summary> /// <param name="user">required UserId, Email, FbId</param> /// <returns></returns> public static async Task <UserDisconnectFbResponse> DisconnectFb(UserModel user) { //salt - d60e82ae4324f250a260a2839cf88498 //disconnect_facebook_fe839ba98fa33d6bdc6fb90951c531e0/ try { string hash = LogicHelper.CreateMD5(user.UserId, "d60e82ae4324f250a260a2839cf88498"); List <string> prms = new List <string> { "?hash=" + hash, "&uid=" + user.UserId, "&email=" + user.Email, "&fbid=" + user.FbId }; HttpHelper helper = new HttpHelper(); string response = await helper.Get("disconnect_facebook_fe839ba98fa33d6bdc6fb90951c531e0/", prms); dynamic obj = JsonConvert.DeserializeObject(response); int status = obj.First["status"]; UserDisconnectFbResponse result = new UserDisconnectFbResponse(); switch (status) { case 100: result.Status = FbDisconnectStatus.Ok; AppInfo.AppUser.FbId = null; result.Response = obj.First["respons"]; break; case 101: result.Status = FbDisconnectStatus.HashError; break; case 102: result.Status = FbDisconnectStatus.UserDontExist; break; case 103: result.Status = FbDisconnectStatus.EmailSendingError; break; case 104: result.Status = FbDisconnectStatus.EmailCheckError; break; case 105: result.Status = FbDisconnectStatus.UserExistsOnEmail; break; case 106: result.Status = FbDisconnectStatus.FacebookUserDontExists; break; case 107: result.Status = FbDisconnectStatus.NoFbId; break; } return(result); } catch { return(null); } }
public static async Task <GameReportStatus> ReportGame(string gid, GameReportTypes type) { try { //salt - b98f8d75ce206d56b4cf759bd13e3cde //game_report_6b761ed643a18e27c6556bf21cbc527c/ string uid = AppInfo.AppUser.UserId; string hash = LogicHelper.CreateMD5(uid, "b98f8d75ce206d56b4cf759bd13e3cde"); string rtype = ""; switch (type) { case GameReportTypes.MisspelledWord: rtype = "1"; break; case GameReportTypes.BadWord: rtype = "2"; break; case GameReportTypes.BadPhoto: rtype = "3"; break; case GameReportTypes.CopyrightedContent: rtype = "4"; break; case GameReportTypes.InappropriateContent: rtype = "5"; break; case GameReportTypes.NudeContent: rtype = "6"; break; case GameReportTypes.OtherIssues: rtype = "7"; break; } List <string> prms = new List <string> { "?hash=" + hash, "&uid=" + uid, "&gid=" + gid, "&rtype=" + rtype }; HttpHelper helper = new HttpHelper(); string response = await helper.Get("game_report_6b761ed643a18e27c6556bf21cbc527c/", prms); dynamic obj = JsonConvert.DeserializeObject(response); int status = obj.First["status"]; switch (status) { case 100: return(GameReportStatus.Ok); case 101: return(GameReportStatus.HashError); case 102: return(GameReportStatus.NotPlayedOrNotStarted); case 103: return(GameReportStatus.SendError); case 104: return(GameReportStatus.ReportError); case 105: return(GameReportStatus.GameError); case 109: return(GameReportStatus.UserError); default: return(GameReportStatus.HashError); } } catch (Exception) { return(GameReportStatus.OtherIssues); } }
public static async Task <UserNativeLoginResponse> LoginNative(string email, string password) { //salt - ff9aa0bbc598d89cffb1e18edf2316d2 //login_native_98c6c5f42b0e82238a5d7d9972800cff try { string hash = LogicHelper.CreateMD5(email, "ff9aa0bbc598d89cffb1e18edf2316d2"); List <string> prms = new List <string> { "?hash=" + hash, "&email=" + email, "&password="******"login_native_98c6c5f42b0e82238a5d7d9972800cff/", prms); dynamic obj = JsonConvert.DeserializeObject(response); UserNativeLoginResponse result = new UserNativeLoginResponse { UserId = obj.First["uid"], UserName = obj.First["uname"], FacebookId = obj.First["fbid"] }; int status = obj.First["status"]; switch (status) { case 100: { result.Status = NativeLoginStatus.Ok; var localSettings = ApplicationData.Current.LocalSettings; localSettings.Values["UserId"] = result.UserId; AppInfo.AppUser = new UserModel { UserId = result.UserId, Name = result.UserName, Email = email, FbId = result.FacebookId }; break; } case 101: { result.Status = NativeLoginStatus.HashError; break; } case 102: { result.Status = NativeLoginStatus.NoUser; break; } case 103: { result.Status = NativeLoginStatus.LoginOrPasswordError; break; } } return(result); } catch { return(null); } }
/// <summary> /// /// </summary> /// <param name="user">required Email, Name, Password, CountryCode, optional PhoneNumber, FbId</param> /// <returns></returns> public static async Task <UserCreateResponse> CreateUser(UserModel user) { //salt - 19cfaaa821b2ac5fc401bfe225deb53c //createuser_2c85e73bc2fa01ff29338a13caf46d88/ try { string hash = LogicHelper.CreateMD5(user.Email, "19cfaaa821b2ac5fc401bfe225deb53c"); List <string> prms = new List <string>() { "?hash=" + hash, "&email=" + user.Email, "&name=" + user.Name, "&password="******"&countrycode=" + user.CountryCode }; if (user.PhoneNumber != null) { prms.Add("&phoneno=" + user.PhoneNumber); } if (user.FbId != null) { prms.Add("&fbid=" + user.FbId); } HttpHelper helper = new HttpHelper(); string response = await helper.Get("createuser_2c85e73bc2fa01ff29338a13caf46d88/", prms); dynamic obj = JsonConvert.DeserializeObject(response); UserCreateResponse result = new UserCreateResponse(); int status = obj.First["status"]; switch (status) { case 100: result.Status = RegisterStatus.Ok; result.UserId = obj.First["uid"]; LogicHelper.SetUserIdToStorage(result.UserId); if (user.ProfilePhoto != null) { UserPhotoUploadResponse photoUploadResponse = await UploadProfilePhoto(user.UserId, user.ProfilePhoto); //if (photoUploadResponse != UserPhotoUploadResponse.Ok) // result.Status = RegisterStatus.PhotoUploadError; } await GetUserData(result.UserId); break; case 101: result.Status = RegisterStatus.HashError; break; case 102: result.Status = RegisterStatus.DbError; break; case 103: result.Status = RegisterStatus.PasswordError; break; case 104: result.Status = RegisterStatus.EmailError; break; case 105: result.Status = RegisterStatus.UserExistsOnEmail; break; case 106: result.Status = RegisterStatus.UserExistsOnFbId; break; case 107: result.Status = RegisterStatus.MissingCountrycode; break; case 110: result.Status = RegisterStatus.MissingParameters; break; case 999: result.Status = RegisterStatus.TokenError; break; } return(result); } catch { UserCreateResponse result = new UserCreateResponse(); result.Status = RegisterStatus.OtherIssues; return(result); } }
/// <summary> /// /// </summary> /// <param name="user">required UserId, Name, Email, CountryCode, PhoneNumber</param> /// <returns></returns> public static async Task <UserDataUpdateResponse> DataUpdate(UserModel user) { //salt - d60e82ae4324f250a260a2839cf88498 //userdata_update_28356a03ad787901d008a1bd92bec877/ try { string hash = LogicHelper.CreateMD5(user.UserId, "d60e82ae4324f250a260a2839cf88498"); HttpHelper helper = new HttpHelper(); List <string> prms = new List <string> { "?hash=" + hash, "&uid=" + user.UserId, "&name=" + user.Name, "&email=" + user.Email, "&countrycode=" + user.CountryCode, "&phoneno=" + user.PhoneNumber }; if (user.FbId != null) { prms.Add("&fbid=" + user.FbId); } string response = await helper.Get("userdata_update_28356a03ad787901d008a1bd92bec877/", prms); dynamic obj = JsonConvert.DeserializeObject(response); int status = obj.First["status"]; UserDataUpdateResponse result = new UserDataUpdateResponse(); switch (status) { //100 = OK //101 = HASH error //102 = User don’t exist //103 = Email error sending //104 = Email error check //105 = User exists on email //106 = User exists on fbid //110 = Email send success case 100: result.Status = UserDataUpdateStatus.Ok; result.Response = obj.First["respons"]; GetUserData(user.UserId); break; case 101: result.Status = UserDataUpdateStatus.HashError; break; case 102: result.Status = UserDataUpdateStatus.UserDontExist; break; case 103: result.Status = UserDataUpdateStatus.EmailSendingError; break; case 104: result.Status = UserDataUpdateStatus.EmailCheckError; break; case 105: result.Status = UserDataUpdateStatus.UserExistsOnEmail; break; case 106: result.Status = UserDataUpdateStatus.UserExistsOnFbId; break; case 110: result.Status = UserDataUpdateStatus.EmailSendSuccess; break; } return(result); } catch { return(null); } }
/// <summary> /// /// </summary> /// <param name="uid"></param> /// <param name="gid"></param> /// <param name="userIds">List of ids for receivers of the challenge comma separation.Mix with: /// gids and/or fbids “FB”+id and/or emails and/or phone-no´s (include countrycode ex. 4526366100)</param> /// <returns></returns> public static async Task <ChallengeCreateResponseModel> CreateChallenge(string gid, List <string> userIds) { //salt - 51454d19b05c53cb3551e3dc617ef4c4 //createchallenge_9ab92ffe8a2f88cd4381570211622dfb/ try { string uid = AppInfo.AppUser.UserId; string hash = LogicHelper.CreateMD5(uid, "51454d19b05c53cb3551e3dc617ef4c4"); string ids = GetIdsString(userIds); List <string> prms = new List <string> { "?hash=" + hash, "&uid=" + uid, "&gid=" + gid, "&ids=" + ids }; HttpHelper helper = new HttpHelper(); string response = await helper.Get("createchallenge_9ab92ffe8a2f88cd4381570211622dfb/", prms); dynamic obj = JsonConvert.DeserializeObject(response); int status = obj["Respons"].First["status"]; ChallengeCreateResponseModel result = new ChallengeCreateResponseModel(); switch (status) { case 100: result.Status = CreateChallengeStatus.Ok; result.ChallengeId = obj["Respons"].First["cid"]; break; case 101: result.Status = CreateChallengeStatus.HashError; break; case 102: result.Status = CreateChallengeStatus.DbError; break; case 103: result.Status = CreateChallengeStatus.NoPlayers; break; case 104: result.Status = CreateChallengeStatus.NoGame; break; case 106: result.Status = CreateChallengeStatus.UserNotAllowed; break; case 110: result.Status = CreateChallengeStatus.MissingParameters; break; case 999: result.Status = CreateChallengeStatus.TokenError; break; } return(result); } catch { return(new ChallengeCreateResponseModel { Status = CreateChallengeStatus.HashError }); } }
public static async Task <List <Puzzle> > GetGameList(string lang, GameSort sort, GameTypes type) { List <Puzzle> result = new List <Puzzle>(); try { //salt - 03f42642c97513dc478fb6e8b4e5c723 //gamelist_eecefb74842cef5ca056cae740ac7fb8/ string userId = AppInfo.AppUser.UserId; string hash = LogicHelper.CreateMD5(userId, "03f42642c97513dc478fb6e8b4e5c723"); string sortString = ""; switch (sort) { case GameSort.StarsDesc: sortString = "GAMES.stars Desc"; break; case GameSort.StarsAsc: sortString = "GAMES.stars Asc"; break; case GameSort.OwlsDesc: sortString = "GAMES.owls Desc"; break; case GameSort.OwlsAsc: sortString = "GAMES.owls Asc"; break; case GameSort.CreatedDesc: sortString = "GAMES.created Desc"; break; case GameSort.TotalStarsDesc: sortString = "GAMES.total_stars Desc"; break; } string gameType = ""; switch (type) { case GameTypes.PuzzleListFromFriends: gameType = "0"; break; case GameTypes.AllPuzzles: gameType = "1"; break; case GameTypes.MyPuzzleList: gameType = "2"; break; case GameTypes.MyPlayedPuzzleList: gameType = "3"; break; case GameTypes.MyCallengesList: gameType = "7"; break; case GameTypes.ChallengeListWithLang: gameType = "8"; break; case GameTypes.ChallengeListAllCahllenges: gameType = "9"; break; } List <string> prms = new List <string> { "?hash=" + hash, "&uid=" + userId, "&from=" + lang, "&sort=" + sortString, ">ype=" + gameType }; HttpHelper helper = new HttpHelper(); string response = await helper.Get("gamelist_eecefb74842cef5ca056cae740ac7fb8/", prms); List <GameModel> obj = JsonConvert.DeserializeObject <List <GameModel> >(response); foreach (var item in obj) { item.GameType = int.Parse(gameType); result.Add(new Puzzle(item)); } } catch (Exception) { await new MessageDialog("An error occurred retrieving puzzles. Please try again later.").ShowAsync(); } return(result); }
public static async Task <GameCreateResponseModel> CreateGame(GameModel model) { //salt - 93bee810428b8b1ecf18ea443c91a07a //creategame_871c1a7c904fe292d43a666626c2b0aa/ string hash = LogicHelper.CreateMD5(model.CreatorUid, "93bee810428b8b1ecf18ea443c91a07a"); Dictionary <string, string> prms = new Dictionary <string, string> { { "hash", hash }, { "uid", model.CreatorUid }, { "gtype", model.CreateGameType }, { "lang", model.Language }, { "word", model.Word } }; //WriteableBitmap image = await LogicHelper.ResizeWritableBitmap(model.Photo, 720, 360); HttpHelper helper = new HttpHelper(); string response = await helper.PostImage("creategame_871c1a7c904fe292d43a666626c2b0aa/", prms, model.Photo); dynamic obj = JsonConvert.DeserializeObject(response); int status = obj["Respons"].First["status"]; GameCreateResponseModel result = new GameCreateResponseModel(); switch (status) { case 100: result.Status = GameCreateStatus.Ok; result.GameId = obj["Respons"].First["gid"]; break; case 101: result.Status = GameCreateStatus.HashError; break; case 102: result.Status = GameCreateStatus.DbError; break; case 103: result.Status = GameCreateStatus.PictureFileError; break; case 104: result.Status = GameCreateStatus.PictureCuttingError; break; case 105: result.Status = GameCreateStatus.NameError; break; case 106: result.Status = GameCreateStatus.UserNotAllowed; break; case 110: result.Status = GameCreateStatus.MisingParameters; break; case 999: result.Status = GameCreateStatus.TokenError; break; } return(result); }
public static async Task <UserFbLoginResponse> LoginFb(string friendsIds = null) { //salt - 29596333de6cb130c92e73de74f1a158 //login_facebook_67e82d4a63d7aa64440593f67221c50b/ try { FacebookHelper fbhelper = new FacebookHelper(); FacebookAccount account = await fbhelper.Login(); UserFbLoginResponse result = null; if (account != null) { string hash = LogicHelper.CreateMD5(account.Id, "29596333de6cb130c92e73de74f1a158"); List <string> prms = new List <string> { "?hash=" + hash, "&fbid=" + account.Id, "&name=" + account.Name, "&email=" + account.Email }; if (friendsIds != null) { prms.Add("&fbids=" + friendsIds); } HttpHelper helper = new HttpHelper(); string response = await helper.Get("login_facebook_67e82d4a63d7aa64440593f67221c50b/", prms); dynamic obj = JsonConvert.DeserializeObject(response); result = new UserFbLoginResponse { UserId = obj.First["uid"], FbId = obj.First["fbid"] }; int status = obj.First["status"]; switch (status) { case 100: { result.Status = FbLoginStatus.Ok; LogicHelper.SetUserIdToStorage(result.UserId); await GetUserData(result.UserId); break; } case 101: { result.Status = FbLoginStatus.HashError; break; } case 102: { result.Status = FbLoginStatus.MissingParameters; break; } case 103: { result.Status = FbLoginStatus.DbError; break; } } } return(result); } catch { var result = new UserFbLoginResponse { Status = FbLoginStatus.CanceledByUser }; return(result); } }