Inheritance: PlayFabRequestCommon
Beispiel #1
0
    /// <summary>
    /// Gets the friends list.
    /// </summary>
    public void GetFriends(Action <Dictionary <string, string> > Callback)
    {
        PlayFab.ClientModels.GetFriendsListRequest request = new PlayFab.ClientModels.GetFriendsListRequest()
        {
            IncludeFacebookFriends = true
        };

        PlayFabClientAPI.GetFriendsList(request, (result) => {
            Dictionary <string, string> dic = new Dictionary <string, string> ();
            foreach (var item in result.Friends)
            {
                dic.Add(item.FacebookInfo.FacebookId, item.FriendPlayFabId);
            }
            Callback(dic);
        }, (error) => {
            Debug.Log(error.ErrorDetails);
        });
    }
Beispiel #2
0
		/// <summary>
		/// Retrieves the current friend list for the local user, constrained to users who have PlayFab accounts. Friends from linked accounts (Facebook, Steam) are also included. You may optionally exclude some linked services' friends.
		/// </summary>
		public static void GetFriendsList(GetFriendsListRequest request, GetFriendsListCallback 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)
			{
				GetFriendsListResult result = null;
				PlayFabError error = null;
				ResultContainer<GetFriendsListResult>.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/GetFriendsList", serializedJSON, "X-Authorization", AuthKey, callback);
		}
        /// <summary>
        /// Retrieves the current friend list for the local user, constrained to users who have PlayFab accounts. Friends from linked accounts (Facebook, Steam) are also included. You may optionally exclude some linked services' friends.
        /// </summary>
        public static void GetFriendsList(GetFriendsListRequest request, ProcessApiCallback<GetFriendsListResult> 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<GetFriendsListResult>.HandleResults(requestContainer, resultCallback, errorCallback, null);
            };
            PlayFabHTTP.Post("/Client/GetFriendsList", serializedJson, "X-Authorization", _authKey, callback, request, customData);
        }
 public static void GetFriendsList()
 {
     var request = new GetFriendsListRequest()
     {
     };
     PlayFabClientAPI.GetFriendsList(request, (result) =>
     {
         foreach(var friend in result.Friends)
         {
             PlayFabDataStore.friendsList.Add(friend.Username, friend.FriendPlayFabId);
         }
         FriendsList.friendsList.LoadFriendsList();
        
     },
     (error) =>
     {
         Debug.Log("Cant get friends list");
         Debug.Log(error.ErrorMessage);
         Debug.Log(error.ErrorDetails);
     });
 }
Beispiel #5
0
		/// <summary>
		/// Retrieves the current friend list for the local user, constrained to users who have PlayFab accounts. Friends from linked accounts (Facebook, Steam) are also included. You may optionally exclude some linked services' friends.
		/// </summary>
        public static async Task<PlayFabResult<GetFriendsListResult>> GetFriendsListAsync(GetFriendsListRequest request)
        {
            if (AuthKey == null) throw new Exception ("Must be logged in to call this method");

            object httpResult = await PlayFabHTTP.DoPost(PlayFabSettings.GetURL() + "/Client/GetFriendsList", request, "X-Authorization", AuthKey);
            if(httpResult is PlayFabError)
            {
                PlayFabError error = (PlayFabError)httpResult;
                if (PlayFabSettings.GlobalErrorHandler != null)
                    PlayFabSettings.GlobalErrorHandler(error);
                return new PlayFabResult<GetFriendsListResult>
                {
                    Error = error,
                };
            }
            string resultRawJson = (string)httpResult;

            var serializer = JsonSerializer.Create(PlayFabSettings.JsonSettings);
            var resultData = serializer.Deserialize<PlayFabJsonSuccess<GetFriendsListResult>>(new JsonTextReader(new StringReader(resultRawJson)));
			
			GetFriendsListResult result = resultData.data;
			
			
            return new PlayFabResult<GetFriendsListResult>
                {
                    Result = result
                };
        }