-3

I have searched for some hours now, and can't find an answer. I have a homepage coded in php that needs to frequently send and receive data to a java program.

So far I have done it via POST, but I wonder if it's a better way to do it. I have tried with sockets. But only managed to find tutorials for php client connecting to a java server. But I need the reverse.

bcesars
  • 1,016
  • 1
  • 17
  • 36
Yemto
  • 613
  • 1
  • 7
  • 18
  • 4
    There is absolutely nothing in the HTTP protocol requiring programming in this or that language, either here or there. And even if you don't use HTTP, there's nothing in sockets that requires programming in some specific language, either client or server side. (But with "home page" and a browser embedding your stuff you better stay with HTTP.) – laune Feb 09 '15 at 19:10
  • @laune I don't understand you comment. – Yemto Feb 09 '15 at 19:13
  • 6
    The programming language does not matter: use whatever you like. – laune Feb 09 '15 at 19:18

1 Answers1

1

All modern languages allow you to send and receive data, no matter from which language is sent or received. Many large applications (such as Facebook API), work with simple methods such as POST, GET, PUT, DELETE, etc., that is a REST API, returning the data in a specific format (JSON, XML, RAW, etc.). This is innecessary if your application is a little piece of code, but you could take this idea and make something simple. So, there is nothing wrong if you are using the POST method, but just in case, I can name you other resources that you could take advantage of.

You can use WebClient.

Also, you can comunicate your PHP code with your Java code using sockets.

Of course, you can use cURL too. For Java you can read this question and connect with php. If your application is very large and complex in the PHP side, I guggest you to use Laravel.

Community
  • 1
  • 1
Tomás Juárez
  • 1,517
  • 3
  • 21
  • 51