Connect Java App to a Wordpress MYSQL Database

Hello

So I’m in the current process of building a launcher for my game. One of the systems I need is login. How the login will work on a general base is the java app will somehow send the username and password encoded (I already know how to do the encoding) to the Wordpress front end and request a login using the username and password. From there WordPress does its normal way of logging in. But instead of returning the website it needs to goto, I would like it to return if the user was accepted or not.

So I would be guessing a plugin on the wordpress side will be required so it can just return true or false. Next will be java, I need a way to send a username and password to wordpress. Though wordpress doesn’t use java, it uses PHP. So is there I can request a php query inside java.

I have looked at XMLRPC but I can’t find a way for just to login to wordpress from that, it seems that you have to use a function to do something to test to see if you can login. If someone knows how to just do login, I wouldn’t mind that either.

Thanks, Sam

MySQL has nothing to do with PHP. What you need to do is simply to connect to the database directly from you java code, and perform the (SQL) query. Do some google searches for “mysql java tutorial”.

It might also be possible to decide if a user is succesfully authenticated based on the HTTP status codes. If wordpress does this in a sane way ::slight_smile:

All you need is the database URL and login credential. Then JDBC will take care of it.

Never ever expose your database to the outside world.

Query WordPress itself, over HTTP. If you want to use a specialized solution, write a JSON API, but I can’t stress enough that a database must be only reachable by a serverside application, where business logic defines the used queries; never execute queries received from a client.

Very good point! I didn’t consider that. Before you know it somebody knows your db host and credentials.

also, perhaps it’s easier for you to use OAuth for your user accounts.

Means that your user can login with their Facebook, Google, Twitter … accounts into your app.

Cant you just post the user credentials to the login form and check the http response code to not be 403?

What makes you think WordPress returns statuscode 403?