Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make calls to jsonapi using Javascript #468

Open
ersgonzalo opened this issue Nov 27, 2015 · 3 comments
Open

Make calls to jsonapi using Javascript #468

ersgonzalo opened this issue Nov 27, 2015 · 3 comments

Comments

@ersgonzalo
Copy link

Hey Mates,

I'm a bit unsure of how to make calls to the JSON Api on my server using Javascript. I want to make more information available on my server's website and take it from the server itself without having to use external services. If this information is documented in the Wiki forgive me for my ignorance but I can't seem to find any at the moment. From what I can gather, process for making a call to a Minecraft server seems to be as so:

  • Install the JSONAPI Plugin to your server (along with the other dependencies as needed)
  • Look into configuration files and save the username and password in the users.yml file for later use
  • If you want to use a salt, include a salt in the config.yml file
  • Look into the Javascript SDK from tools and load it as one of the scripts for the index.html
  • In my own script.js file, insert this:
    var j = new jsonapi({ hostname: "serverIP/domainName", port: 20059, username: "usernameFromUsers.yml", password: "passwordFromUsers.yml", salt: "saltFromConfig.yml" });
  • And then make calls, like so: j.call('getPlayers', console.log);

However, I seem to get errors with my server and nothing is returned from my get requests. Could I get some help with this?

@krisdb2009
Copy link

What are the errors?

@ersgonzalo
Copy link
Author

I get two errors:

  • If I use port '25565' Uncaught ReferenceError: Invalid left-hand side in assignment
  • If I use port '20059' I get 'Not Found' as a response from the server
    I can see messages on the server if I use port 25565 but not 20059

@Kworz
Copy link

Kworz commented Nov 28, 2015

Better use Websockets :)
but you will have to use CryptoJS / Other SHA256 crypting system

var socket = new WebSocket("ws://****YOURIP****:20061/");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants