Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [FunctionName("HelloWorld")]
- public static async Task<dynamic> Run(
- [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
- ILogger log)
- {
- string bd = await req.ReadAsStringAsync();
- log.LogInformation($" req.Body: { bd}");
- FunctionExecutionContext<dynamic> context = JsonConvert.DeserializeObject<FunctionExecutionContext<dynamic>>(bd);
- // log.LogInformation($"req body: {new StreamReader(httpRequest.Body).ReadToEnd()}");
- // var context2 = JsonConvert.DeserializeObject<FunctionExecutionContext<dynamic>>(await req.ReadAsStringAsync());
- var serverSettings = new PlayFab.PlayFabApiSettings()
- {
- TitleId = Environment.GetEnvironmentVariable("PLAYFAB_TITLE_ID"),
- DeveloperSecretKey = Environment.GetEnvironmentVariable("PLAYFAB_DEV_SECRET_KEY")
- };
- var titleAuthContext = new PlayFabAuthenticationContext();
- //titleAuthContext.EntityToken = context.TitleAuthenticationContext.EntityToken;
- var s = new PlayFabEconomyInstanceAPI(serverSettings,titleAuthContext);
- var lootboxItemRef = new PlayFab.EconomyModels.InventoryItemReference
- {
- Id = "45d5a69f-63eb-4fe9-bb17-3461526d6a61",
- StackId = "default"
- };
- PlayFab.EconomyModels.EntityKey entity = new PlayFab.EconomyModels.EntityKey {
- Id = context.CallerEntityProfile.Entity.Id, Type = context.CallerEntityProfile.Entity.Type
- };
- var request = new AddInventoryItemsRequest(){
- Amount = 1,
- Entity = entity,
- Item = lootboxItemRef
- };
- return await s.AddInventoryItemsAsync(request);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement