/// <summary> /// Place the friends on map. /// </summary> public void PlaceFriendsPositionsOnMap(Action <Dictionary <string, int> > Callback) { Debug.Log("place friends"); PlayFab.ClientModels.GetFriendLeaderboardRequest request = new PlayFab.ClientModels.GetFriendLeaderboardRequest() { StatisticName = "Level", IncludeFacebookFriends = true }; PlayFabClientAPI.GetFriendLeaderboard(request, (result) => { Dictionary <string, int> dic = new Dictionary <string, int> (); foreach (var item in result.Leaderboard) { dic.Add(item.PlayFabId, item.StatValue); } Callback(dic); }, (error) => { Debug.Log(error.ErrorDetails); }); }
/// <summary> /// Retrieves a list of ranked friends of the current player for the given statistic, starting from the indicated point in the leaderboard /// </summary> public static void GetFriendLeaderboard(GetFriendLeaderboardRequest request, GetFriendLeaderboardCallback resultCallback, ErrorCallback errorCallback) { if (AuthKey == null) throw new Exception ("Must be logged in to call this method"); string serializedJSON = JsonConvert.SerializeObject(request, Util.JsonFormatting, Util.JsonSettings); Action<string,string> callback = delegate(string responseStr, string errorStr) { GetLeaderboardResult result = null; PlayFabError error = null; ResultContainer<GetLeaderboardResult>.HandleResults(responseStr, errorStr, out result, out error); if(error != null && errorCallback != null) { errorCallback(error); } if(result != null) { if(resultCallback != null) { resultCallback(result); } } }; PlayFabHTTP.Post(PlayFabSettings.GetURL()+"/Client/GetFriendLeaderboard", serializedJSON, "X-Authorization", AuthKey, callback); }
/// <summary> /// Retrieves a list of ranked friends of the current player for the given statistic, starting from the indicated point in the leaderboard /// </summary> public static void GetFriendLeaderboard(GetFriendLeaderboardRequest request, ProcessApiCallback<GetLeaderboardResult> resultCallback, ErrorCallback errorCallback, object customData = null) { if (_authKey == null) throw new Exception("Must be logged in to call this method"); string serializedJson = SimpleJson.SerializeObject(request, Util.ApiSerializerStrategy); Action<CallRequestContainer> callback = delegate(CallRequestContainer requestContainer) { ResultContainer<GetLeaderboardResult>.HandleResults(requestContainer, resultCallback, errorCallback, null); }; PlayFabHTTP.Post("/Client/GetFriendLeaderboard", serializedJson, "X-Authorization", _authKey, callback, request, customData); }
/// <summary> /// Retrieves a list of ranked friends of the current player for the given statistic, starting from the indicated point in the leaderboard /// </summary> public static async Task<PlayFabResult<GetLeaderboardResult>> GetFriendLeaderboardAsync(GetFriendLeaderboardRequest request) { if (AuthKey == null) throw new Exception ("Must be logged in to call this method"); object httpResult = await PlayFabHTTP.DoPost(PlayFabSettings.GetURL() + "/Client/GetFriendLeaderboard", request, "X-Authorization", AuthKey); if(httpResult is PlayFabError) { PlayFabError error = (PlayFabError)httpResult; if (PlayFabSettings.GlobalErrorHandler != null) PlayFabSettings.GlobalErrorHandler(error); return new PlayFabResult<GetLeaderboardResult> { Error = error, }; } string resultRawJson = (string)httpResult; var serializer = JsonSerializer.Create(PlayFabSettings.JsonSettings); var resultData = serializer.Deserialize<PlayFabJsonSuccess<GetLeaderboardResult>>(new JsonTextReader(new StringReader(resultRawJson))); GetLeaderboardResult result = resultData.data; return new PlayFabResult<GetLeaderboardResult> { Result = result }; }