question

DevVIE avatar image
DevVIE asked

How to manager player data from another web?

 <title>BW Manager</title>
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
 <script>
   var titleId = "my title id";
   var developerSecretKey = "my secret key";
   var apiEndpoint = "https://my title id.playfabapi.com/";

   function connectToPlayFab() 
   {
     $.ajax
     ({
       type: "POST",
       url: apiEndpoint,
       headers: 
       {
         "X-SecretKey": developerSecretKey.toUpperCase()
       },
       success: function () 
       {
         console.log("Đã kết nối tới PlayFab");

         // Gọi hàm truy xuất tất cả người dùng
         getAllUsers();
       },
       error: function () 
       {
         console.log("Lỗi khi kết nối tới PlayFab");
       }
     });
   }

   function getAllUsers() 
   {
     $.ajax
     ({
       type: "POST",
       url: apiEndpoint + "Admin/GetAllUsers",
       headers: 
       {
         "X-SecretKey": developerSecretKey.toUpperCase()
       },
       success: function (data) 
       {
         console.log("Dữ liệu người dùng: ", data);

         // Hiển thị danh sách người dùng lên trang web
         var userList = $("#user-list");
         for (var i = 0; i < data.data.Users.length; i++) 
         {
           userList.append("<li>" + data.data.Users[i].Username + "</li>");
         }
       },
       error: function () 
       {
         console.log("Lỗi khi truy xuất người dùng");
       }
     });
   }

   $(document).ready(function () 
   {
     connectToPlayFab();
   });
 </script>
  
  
 <h1>Truy xuất dữ liệu</h1>
 <ul id="user-list"></ul>

I have no experience with web writing, I only have experience writing game code so maybe this web code is faulty somewhere. please help me fix it

Player Datagame manager
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Xiao Zha avatar image
Xiao Zha answered

According to the code you provided, it is found that the GetAllUser API you call does not exist. If you want to get the usernames of all the players in your title to display a user list on the website, you can call Admin/GetPlayersInSegment with All Player segment Id to get all the players, in batches of 10,000. Just use the ContinuationToekn to get the next batch of 10,000 until you reach the end.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.