Reputation: 361
I'm working on a chess site and I've implemented a rule checker in PHP and I use that on my main site at http://www.chesslords.net/, but, I'm working on an Android frontend in the meantime. However, after I've added the event and drawing correctly to my project, I would like to use my foo.php from my bar.java, calling the rulechecker to generate slots. Do you know how to do that? Thanks in advance for your answer.
Upvotes: 4
Views: 4725
Reputation: 1026
For this kind of purpose i have recently coded a http client in php scripting which solves your query. It can post the data to the server after that you can save it to the database.
http://webtoocool.wordpress.com/2010/07/30/http-client-pfa/
Upvotes: 0
Reputation: 643
Your PHP backend needs to expose an API to the network. It doesn't have to be a specific API or technology (SOAP, JSON, REST, XML-RPC, etc.) Almost any will work as long as you settle on one technique. Having said that, a REST api with JSON encoded data is particularly well suited for Android mobile applications.
Here's an article on creating a REST API in PHP for your backend: http://www.gen-x-design.com/archives/create-a-rest-api-with-php/
Here's one of this years Google IO talks on consuming REST API's in Android: http://code.google.com/events/io/2010/sessions/developing-RESTful-android-apps.html
Those two links should at least get you started.
I'd suggest starting with implementing the server side of the API on your chess website first, possibly testing it with a simple PHP client application, just some simple test scripts to fire of sample request to your service and then look at the returned results.
After you've got the backend working, implementing your Android front-end client should be fairly straightforward.
Upvotes: 2
Reputation: 4031
The PHP backend on the server is just going to be bound to URLs, so you'll just be using HTTP requests to get to it - probably by creating an new URL, calling openConnection(), and then using the input and output streams from that.
Upvotes: 1