dslfjrmz70457 2015-02-09 19:06
浏览 60
已采纳

PHP服务器和JAVA客户端可能吗? [关闭]

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.

  • 写回答

1条回答 默认 最新

  • dsq30861 2015-02-09 19:23
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?