Could you give code examples please?
Could you give code examples please?
Players can call API SearchItems to execute a search against the public catalog using the provided search parameters. For more info, you can refer to https://learn.microsoft.com/en-us/gaming/playfab/features/economy-v2/quickstart?tabs=secret-key-api%2Ccatalog-settings-game-manager%2Cpublish-item-game-manager%2Csearch-game-manager%2Cvirtual-currency-game-manager%2Cgrant-currency-game-manager%2Ccreate-catalog-item-game-manager#step-4---do-a-search. The currency in Economy V2 is also an item, and players can use the API GetInventoryItems with the request parameter "Filter" to specify what type of item they want to retrieve. For more info, please refer to https://learn.microsoft.com/en-us/gaming/playfab/features/economy-v2/inventory/?tabs=inventory-api#getting-a-players-inventory. And you can also refer to my testing code examples below:
public void SearchItemsTest()
{
PlayFabEconomyAPI.SearchItems(new PlayFab.EconomyModels.SearchItemsRequest()
{
Count = 10
},
result => {
Debug.Log("Search items successfully");
foreach (var item in result.Items)
{
Debug.Log("Item ID:"+ item.Id);
//Print out the searched item id
}
},
error => {
Debug.Log("Got error searching items");
Debug.Log(error.GenerateErrorReport());
});
}
public void RetrieveInventoryTest()
{
PlayFabEconomyAPI.GetInventoryItems(new PlayFab.EconomyModels.GetInventoryItemsRequest()
{
Count = 10,
Filter = "type eq 'currency'"
},
result => {
Debug.Log("Retrieve inventory items successfully");
foreach (var item in result.Items)
{
Debug.Log("Item ID:" + item.Id);
//Print out the retrieved item id
}
},
error => {
Debug.Log("Got error");
Debug.Log(error.GenerateErrorReport());
});
}
1 Person is following this question.