@@ -55,8 +55,71 @@ Our Developer Success Team can assist with answering any questions as well as pr
5555
5656[ Forums, Support and Knowledge Base] ( https://community.playfab.com/hc/en-us )
5757
58+ 6 . Example Usage (Template):
59+ ----
60+
61+ ```
62+ // In this javascript example, it is assumed your html will include the PlayFab JavaScript Client SDK
63+ // For example, in your html header, add this:
64+ // <script src="https://download.playfab.com/PlayFabClientApi.js"></script>
65+
66+ // You must always set your titleId first
67+ PlayFab.settings.titleId = null; // Set your titleId here. Example: "6195"
68+
69+ // Utility function (We may add this to the core sdk later)
70+ function CompileErrorReport(error) {
71+ if (error == null)
72+ return "";
73+ var fullErrors = error.errorMessage;
74+ for (var paramName in error.errorDetails)
75+ for (var msgIdx in error.errorDetails[paramName])
76+ fullErrors += "\n" + paramName + ": " + error.errorDetails[paramName][msgIdx];
77+ return fullErrors;
78+ }
79+
80+ // Define a callback function (In this case for any PlayFab-Login)
81+ function OnLogin(response, error) {
82+ if (response && response["code"] == 200) {
83+ console.log("Login Successful: " + response.data.PlayFabId)
84+ }
85+ else {
86+ console.log("LoginWithEmailAddress Failed: \n" + CompileErrorReport(error))
87+ }
88+ }
89+
90+ // Username and email is a typical login for Web-Pages
91+ function ExampleLoginWithEmailAddress(email, password)
92+ {
93+ // Request JSON
94+ var loginRequest = {
95+ TitleId: PlayFab.settings.titleId,
96+ "Email": email,
97+ "Password": password
98+ };
99+ // https://api.playfab.com/Documentation/Client/method/LoginWithEmailAddress
100+ PlayFabClientSDK.LoginWithEmailAddress(loginRequest, OnLogin);
101+ }
102+
103+ // CustomId should only be used for testing or evaluating PlayFab, but it can be any string
104+ function ExampleLoginWithCustomId(customId) {
105+ // Request JSON
106+ var loginRequest = {
107+ TitleId: PlayFab.settings.titleId,
108+ CustomId: PlayFab._internalSettings.buildIdentifier,
109+ CreateAccount: true
110+ };
111+ // https://api.playfab.com/Documentation/Client/method/LoginWithCustomID
112+ PlayFabClientSDK.LoginWithCustomID(loginRequest, OnLogin);
113+ }
114+ ```
115+
116+
117+ 7 . Acknowledgements
118+ ----
119+ Example Usage provided by [ dylanh724] ( https://www.github.com/dylanh724 )
120+
58121
59- 6 . Copyright and Licensing Information:
122+ 8 . Copyright and Licensing Information:
60123----
61124 Apache License --
62125 Version 2.0, January 2004
0 commit comments