question

1508985 avatar image
1508985 asked

Java API - Stupid question

Hi, I am wondering how to code PlayFab into a game that I am working on in Java, I've tried using javascript within Java but I am just getting javax.script.ScriptException: ReferenceError: "XMLHttpRequest" is not defined in <eval> at line number 60

Any help for an idiot that has no idea how to code this?...

apissdksContent
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

·
brendan avatar image
brendan answered

XMLHttpRequest is a JavaScript component in web browsers. If you're developing in straight Java, I'd recommend using this guide: https://api.playfab.com/docs/getting-started/java-getting-started.

7 comments
10 |1200

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

1508985 avatar image 1508985 commented ·

@Brendan thanks, I have been looking through the link and I was still unable to find any examples except from the creation of a new user. Is there any additional guides that show code examples for GetTitleData etc for use within the games.

0 Likes 0 ·
brendan avatar image brendan 1508985 commented ·

We have a number of examples in our tutorials (like this one: https://api.playfab.com/docs/tutorials/landing-content/using-title-data), but all the API calls are simple Web API endpoints, so effectively they're all basically the same, in how you construct them. We'll be adding more tabs to the examples in the tutorials as soon as we can.

0 Likes 0 ·
1508985 avatar image 1508985 commented ·

@Brendan sorry, I’m still being blank with how to make these work with Java.

When I call any of the methods it just gives me syntax errors, any code snippets written in Java would be amazing.

Sorry,

Thank you for all your help

0 Likes 0 ·
brendan avatar image brendan 1508985 commented ·

Can you provide the details of the calls you're making, and the responses?

0 Likes 0 ·
1508985 avatar image 1508985 commented ·

@brendan my current ideas is to have the game pull down the game title information for global stuff like screen size and the game FPS. Then use the user data to store things like ammo, score and level. Then write the user data back to playfab after each level.

Sorry I’ve never used PlayFab before so I’m not used to how you build constructors for the functions

0 Likes 0 ·
1508985 avatar image 1508985 commented ·

@Brendan

Basically, I'm needing to know how to pull player inventory in Java and how it will be saved.

How to run cloud scripts and get return values.

Pull Game Title information

0 Likes 0 ·
brendan avatar image brendan 1508985 commented ·

What you'll want to do is use our Java SDK (https://api.playfab.com/docs/getting-started/java-getting-started) and make the calls the way shown in the readme of the GitHub repo containing the SDK - look below where it says "Set up your first API call". All the parameters for the calls are defined in our documentation, to help make this simple.

0 Likes 0 ·

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.