brainCloud's APIs are designed to segregate global data (i.e. Global Entities) from user data (i.e. User Entities) - and to ensure that the actions of one user cannot inadvertently affect the private data of another user.
That said, there may be times when you want more access to another player's data. Here are some options available to you:
User Summary Data
User Summary Data (also referred to as Player Summary Data and/or Friend Data) is special information that a user *advertises* about themselves. This is a great spot to place data that you want to make available and easily accessible to other users.
You set user summary data via the UpdateSummaryFriendData() API. Another user can read it via the GetSummaryDataForProfileId() call.
Pro-tip: Summary Data is automatically returned during leaderboard and matchmaking calls - so a lot of the time you don't need to specifically request it at all!
Shared Data API
The developer can also choose to make some data entities available for access by other users.
To do so, the Entity should first be created with an { "other": 1}
or { "other": 2}
ACL permission, so that other users will have access to the object.
The requesting user can then retrieve the other user's shared entities via the Shared Data API of the User Entity Service.
Get Session for Profile
There are times when you need to go further - and actually *pretend* to be the other user. This can be useful when recording the scores for both players in an offline match that just completed, for example.
For those times, brainCloud provides the GetSessionForProfile() method on the cloud code bridge object.
Once you retrieve a session, you can then pass that session to the proxy retrieval methods, and access any of brainCloud's API calls as if you were that user.
For example, to post the other user's match results:
var otherSession = bridge.getSessionForProfile(OtherProfileId);
var otherLeaderboardService =
bridge.getLeaderboardServiceProxy(otherSession);
var result =
otherLeaderboardService.postScoreToLeaderboard(
leaderboardId, score, data);
Your feedback is important to us. Please rate this response below. Thanks!