### Install PlayFab Example Testing Project Source: https://github.com/playfab/nodesdk/blob/master/PlayFabSdk/README.md Installs the example automated-testing project for the PlayFab Node.js SDK. Requires Node.js to be installed. ```bash npm install playfab-testing ``` -------------------------------- ### PlayFab Client API Documentation Reference Source: https://github.com/playfab/nodesdk/blob/master/PlayFabSdk/NodeGettingStarted.md Provides a reference to the PlayFab Client API, including methods for various game operations. It directs users to the official documentation for detailed information on specific API calls, their parameters, and return values. ```APIDOC PlayFabClient: LoginWithCustomID(request, callback) - Logs in a user with a custom identifier. - Parameters: - request: An object containing login details such as TitleId, CustomId, and CreateAccount flag. - TitleId: string (required) - The unique identifier for your PlayFab title. - CustomId: string (required) - A custom identifier for the user. - CreateAccount: boolean (optional) - If true, creates a new account if one does not exist for the CustomId. - callback: A function to handle the response. It receives two arguments: error and result. (See https://api.playfab.com/Documentation/Client/ for a complete list of client API calls) ``` -------------------------------- ### PlayFab Login with Custom ID Example Source: https://github.com/playfab/nodesdk/blob/master/PlayFabSdk/NodeGettingStarted.md Demonstrates how to perform a login operation using a custom ID with the PlayFab SDK for Node.js. It includes setting the Title ID, making the LoginWithCustomID request, and handling the callback with success or error messages. ```JavaScript var playfab = require('playfab-sdk') var PlayFab = playfab.PlayFab var PlayFabClient = playfab.PlayFabClient function DoExampleLoginWithCustomID() { PlayFab.settings.titleId = "144"; var loginRequest = { // Currently, you need to look up the correct format for this object in the API-docs: // https://api.playfab.com/Documentation/Client/method/LoginWithCustomID TitleId: PlayFab.settings.titleId, CustomId: "GettingStartedGuide", CreateAccount: true }; PlayFabClient.LoginWithCustomID(loginRequest, LoginCallback); } function LoginCallback(error, result) { if (result !== null) { console.log("Congratulations, you made your first successful API call!"); } else if (error !== null) { console.log("Something went wrong with your first API call."); console.log("Here's some debug information:"); console.log(CompileErrorReport(error)); } } // This is a utility function we haven't put into the core SDK yet. Feel free to use it. function CompileErrorReport(error) { if (error == null) return ""; var fullErrors = error.errorMessage; for (var paramName in error.errorDetails) for (var msgIdx in error.errorDetails[paramName]) fullErrors += "\n" + paramName + ": " + error.errorDetails[paramName][msgIdx]; return fullErrors; } // Kick off the actual login call DoExampleLoginWithCustomID(); ``` -------------------------------- ### PlayFab API Documentation Reference Source: https://github.com/playfab/nodesdk/blob/master/TypeScriptGettingStarted.md Provides a reference to available PlayFab client API calls. For a comprehensive list, consult the official PlayFab API documentation. ```APIDOC PlayFab Client API: LoginWithCustomID(request: PlayFabClientModels.LoginWithCustomIDRequest, callback: function): - Logs the user in using a custom identifier. - Parameters: - request: An object containing the login details, including CustomId and CreateAccount flag. - callback: A function to handle the response, receiving error or success data. - Returns: LoginResult object on success, or an IPlayFabError object on failure. Notes: - PlayFab.settings.titleId must be set before making API calls. - The CompileErrorReport utility function can be used to format error details. ``` -------------------------------- ### PlayFab Login with Custom ID Example Source: https://github.com/playfab/nodesdk/blob/master/TypeScriptGettingStarted.md Demonstrates how to perform a login operation using a custom ID with the PlayFab SDK. It includes setting the title ID, creating a login request, and handling the callback for success or failure. ```TypeScript var PlayFab: PlayFabModule.IPlayFab = require("PlayFab-sdk/Scripts/PlayFab/PlayFab"); var PlayFabClient: PlayFabClientModule.IPlayFabClient = require("PlayFab-sdk/Scripts/PlayFab/PlayFabClient"); function DoExampleLoginWithCustomID(): void { PlayFab.settings.titleId = "144"; var loginRequest: PlayFabClientModels.LoginWithCustomIDRequest = { CustomId: "GettingStartedGuide", CreateAccount: true }; PlayFabClient.LoginWithCustomID(loginRequest, LoginCallback); } function LoginCallback(error: PlayFabModule.IPlayFabError, result: PlayFabModule.IPlayFabSuccessContainer): void { if (result !== null) { console.log("Congratulations, you made your first successful API call!"); } else if (error !== null) { console.log("Something went wrong with your first API call."); console.log("Here's some debug information:"); console.log(CompileErrorReport(error)); } } // This is a utility function we haven't put into the core SDK yet. Feel free to use it. function CompileErrorReport(error: PlayFabModule.IPlayFabError): string { if (error == null) return ""; var fullErrors: string = error.errorMessage; for (var paramName in error.errorDetails) for (var msgIdx in error.errorDetails[paramName]) fullErrors += "\n" + paramName + ": " + error.errorDetails[paramName][msgIdx]; return fullErrors; } // Kick off the actual login call DoExampleLoginWithCustomID(); ``` -------------------------------- ### PlayFab Client SDK Authentication Methods Source: https://github.com/playfab/nodesdk/blob/master/PlayFabSdk/NodeGettingStarted.md Provides links to various PlayFab client SDK authentication methods, such as LoginWithAndroidDeviceID, LoginWithIOSDeviceID, and LoginWithEmailAddress. This section highlights that LoginWithCustomID is a basic example and other methods are often preferred for production environments. ```APIDOC PlayFab Client SDK Authentication: - LoginWithCustomID(request) - Description: Logs in using a custom identifier. Suitable for getting started or specific use cases. - Parameters: - request: An object containing TitleId, CustomId, and CreateAccount. - Callback: Receives error or result object. - LoginWithAndroidDeviceID(request) - Description: Logs in using the Android Device ID. - Link: https://api.playfab.com/Documentation/Client/method/LoginWithAndroidDeviceID - LoginWithIOSDeviceID(request) - Description: Logs in using the iOS Device ID. - Link: https://api.playfab.com/Documentation/Client/method/LoginWithIOSDeviceID - LoginWithEmailAddress(request) - Description: Logs in using email address and password. - Link: https://api.playfab.com/Documentation/Client/method/LoginWithEmailAddress - General Authentication Documentation: - Link: https://api.playfab.com/Documentation/Client#Authentication ``` -------------------------------- ### PlayFab SDK Initialization and Login Source: https://github.com/playfab/nodesdk/blob/master/PlayFabSdk/NodeGettingStarted.md Demonstrates how to set the PlayFab titleId, construct a login request object with a custom ID, and initiate the login process using PlayFabClientSDK.LoginWithCustomID. It also outlines the structure of the callback function for handling login results and errors. ```javascript PlayFab.settings.titleId = "xxxx"; var loginRequest = { TitleId: PlayFab.settings.titleId, CustomId: "GettingStartedGuide", CreateAccount: true }; PlayFabClientSDK.LoginWithCustomID(loginRequest, LoginCallback); function LoginCallback(error, result) { if (error) { console.error("Login failed:", error.errorMessage); } else { console.log("Login successful:", result); } } ``` -------------------------------- ### PlayFab Client API - LoginWithCustomID Source: https://github.com/playfab/nodesdk/blob/master/TypeScriptGettingStarted.md This section details the LoginWithCustomID method of the PlayFab Client API. It outlines the required request object, the asynchronous callback mechanism, and common error conditions. It also references other login methods available in the PlayFab SDK. ```APIDOC PlayFabClientSDK.LoginWithCustomID(loginRequest, LoginCallback); LoginWithCustomID: - Description: Logs the user in using a custom ID. This is a common method for identifying players. - Request Object (loginRequest): - CustomId: string (Mandatory) - A unique identifier for the player. - CreateAccount: boolean (Optional) - If true, creates a new account if one does not exist for the CustomId. - TitleId: string (Mandatory in JavaScript) - The Title ID of your PlayFab project. Must match PlayFab.settings.titleId. - Callback Function (LoginCallback): - Parameters: - error: object | null - Contains error information if the API call fails. If null, the call was successful. - result: object | null - Contains the result of the API call if successful. Includes basic player information. - Error Handling: - PlayFabSettings.TitleId not set. - Incorrect or missing request parameters. - Device connectivity issues. - PlayFab server issues. - Network unreliability. - Related Methods: - LoginWithAndroidDeviceID - LoginWithIOSDeviceID - LoginWithEmailAddress - Documentation Link: https://api.playfab.com/Documentation/Client#Authentication ``` -------------------------------- ### PlayFab Client API Usage Example Source: https://github.com/playfab/nodesdk/blob/master/PlayFabSdk/README.md Demonstrates how to use the PlayFab Node.js SDK to interact with the PlayFab Client API. This example shows how to set the titleId and retrieve title data. ```javascript var PlayFabClient = require('./Scripts/PlayFab/PlayFabClient.js') PlayFabClient.settings.titleId = "F00"; PlayFabClient.GetTitleData({Keys : ["Sample"]}, function(error, result) { if(error) { console.log("Got an error: ",error); return; } console.log("Reply: ",result); }); ``` -------------------------------- ### Install PlayFab Node.js SDK Source: https://github.com/playfab/nodesdk/blob/master/PlayFabSdk/README.md Installs the PlayFab SDK for Node.js applications using npm. Requires Node.js to be installed. ```bash npm install playfab-sdk ``` -------------------------------- ### PlayFab API Call Failure Reasons Source: https://github.com/playfab/nodesdk/blob/master/PlayFabSdk/NodeGettingStarted.md Details common reasons why PlayFab API calls might fail, including unconfigured TitleId, incorrect request parameters, device connectivity issues, PlayFab server problems, and general internet unreliability. It also suggests resources for further debugging. ```APIDOC PlayFab API Call Failure Analysis: Common Failure Causes: 1. **PlayFabSettings.TitleId Not Set**: Ensure PlayFab.settings.titleId is correctly configured. 2. **Request Parameters**: Verify that all required parameters for the specific API call are provided and valid. Check error.errorMessage, error.errorDetails, or error.GenerateErrorReport() for details. 3. **Device Connectivity**: Network interruptions (e.g., entering a tunnel) can cause temporary failures. API calls may succeed immediately after. 4. **PlayFab Server Issues**: Occasional server-side problems can occur. Refer to PlayFab release notes for updates. 5. **Internet Reliability**: Network packet corruption or transmission failures can lead to API call failures. Debugging Resources: - **Error Information**: Utilize error.errorMessage, error.errorDetails, and error.GenerateErrorReport() for detailed insights. - **PlayFab Forums**: For persistent issues or complex debugging, visit the community forums: https://community.playfab.com/index.html - **Release Notes**: Check for known issues and updates: https://api.playfab.com/releaseNotes/ ``` -------------------------------- ### New 2.x Require Syntax for PlayFab NodeSDK Source: https://github.com/playfab/nodesdk/blob/master/upgrade.md Demonstrates the correct way to import the PlayFab NodeSDK in version 2.x. This new syntax consolidates all functionalities into a single module import, aligning with standard Node.js package conventions. It shows how to access different parts of the SDK like settings and client APIs. ```javascript var playfab = require("playfab-sdk"); var PlayFabClient = playfab.PlayFabClient; console.log("PlayFab Exists: " + (playfab != null)); console.log("PlayFab settings Exists: " + (playfab.settings != null)); console.log("PlayFab client Exists: " + (playfab.PlayFabClient != null)); for(var each in playfab) { console.log("Each : " + each); } for(var each in playfab.settings) { console.log("Each.settings : " + each); } console.log("Login Function: " + (PlayFabClient.LoginWithCustomID != undefined)); ``` -------------------------------- ### Old 1.x Require Syntax (To be Deleted) Source: https://github.com/playfab/nodesdk/blob/master/upgrade.md Illustrates the outdated require statements used in PlayFab NodeSDK version 1.x. These should be removed and replaced with the new 2.x syntax. The old method involved importing individual files by their full path, which is not standard Node.js practice and has been resolved in version 2.x. ```javascript var playfab = require("./node_modules/playfab-sdk/scripts/PlayFab/PlayFab.js"); var PlayFabClient = require("./node_modules/playfab-sdk/scripts/PlayFab/PlayFabClient.js"); for(var each in playfab) { console.log("Each : " + each); } for(var each in playfab.settings) { console.log("Each.settings : " + each); } console.log("Login Function: " + (PlayFabClient.LoginWithCustomID != undefined)); ``` -------------------------------- ### Set Test Title Data JSON Path Source: https://github.com/playfab/nodesdk/blob/master/PlayFabSdk/README.md Sets an environment variable to specify the full path to the testTitleData.json file, which is required for the example unit-test-project. ```bash set PF_TEST_TITLE_DATA_JSON="C:/YOUR_PATH/testTitleData.json"; ``` -------------------------------- ### Set Developer Secret Key Source: https://github.com/playfab/nodesdk/blob/master/PlayFabSdk/README.md Shows how to set the developerSecretKey for PlayFab Server and Admin APIs. This key should never be exposed to players. ```javascript PlayFabClient.settings.developerSecretKey = "your secret key"; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.