public void REGISTER(string username, string emailAddress, string password)
{ // ACCESING THE PLAYFABCLIENTAPI NAMESPACE
PlayFabClientAPI.RegisterPlayFabUser(// ACCESSING A METHOD IN THE NAMESPACE "REGISTERPLAYFABUSER"
// SENDING THE REQUIRED PARAMETERS FOR THE METHOD TO WORK
// THE "new" REQUEST METHOD IS PART OF THE APICLIENTMODELS NAMESPACE
// IT IS GOING TO STRUCTURE THE HEADER OF OUR API REQUEST FOR US
new RegisterPlayFabUserRequest()
{
Email = emailAddress,
Password = password,
Username = username,
RequireBothUsernameAndEmail = true
},
response =>
{
// The thing to notify the user that a new account has been created successfully
Debug.Log($"Account created friend! : {username}, {emailAddress}");
},
error =>
{
Debug.Log($"Account not created am sad! : {username}, {emailAddress} \n {error.ErrorMessage}");
}
);
}
// THE PlayFabUserRequest ARGUMENT GENERATES A HEADER BASED ON THE PARAMETERS WE PUT IN IT FROM THE FUNCTION CALL IN THE ABOVE CODE BLOCK WHICH WAS IN A DIFFERENT NAMESPACE. IT ALSO AUTOMATICALLY RETURNS THE TITLEID AND AUTHENTICATION CREDENTIALS, PROVIDED PLAYFAB WAS SETUP PROPERLY, THAT WILL MAKE THE API WORK.
//NOTE: The PlayFabUserRequest argument is also a seperate namespace part of the ClientModels namespace in this ex.
public static void RegisterPlayFabUser(RegisterPlayFabUserRequest request, Action<RegisterPlayFabUserResult> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
{
var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer;
var callSettings = PlayFabSettings.staticSettings;
request.TitleId = request.TitleId ?? callSettings.TitleId;
// THIS IS THE PART THAT MAKES THE ACTUAL API REQUEST
PlayFabHttp.MakeApiCall("/Client/RegisterPlayFabUser", request, AuthType.None, resultCallback, errorCallback, customData, extraHeaders, context, callSettings);
}
The online documentation is not the best but lets take a look at it anyway hopefully it makes much more sense now
Name | Required | Type | Description |
---|---|---|---|
None | True | string | This API requires no authentication headers (usually provides one to other calls). |
Name | Required | Type | Description |
---|---|---|---|
TitleId | True |
string |
Unique identifier for the title, found in the Settings > Game Properties section of the PlayFab developer site when a title has been selected. |
CustomTags |
object |
The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.). |
|
DisplayName |
string |
An optional parameter for setting the display name for this title (3-25 characters). |
|
string |
User email address attached to their account |
||
EncryptedRequest |
string |
Base64 encoded body that is encrypted with the Title's public RSA key (Enterprise Only). |
|
InfoRequestParameters |
Flags for which pieces of info to return for the user. |
||
Password |
string |
Password for the PlayFab account (6-100 characters) |
|
PlayerSecret |
string |
Player secret that is used to verify API request signatures (Enterprise Only). |
|
RequireBothUsernameAndEmail |
boolean |
An optional parameter that specifies whether both the username and email parameters are required. If true, both parameters are required; if false, the user must supply either the username or email parameter. The default value is true. |
|
Username |
string |
PlayFab username for the account (3-20 characters) |