douaonong7807 2014-09-22 11:37
浏览 45
已采纳

我需要Web API或普通的Web服务吗? [关闭]

My Android app calls for some data that I have stored in my database. I've worked with some Java Dynamic Web Apps, wherein they'll use cxf and write web APIs, catering to the requests. This seemed like the obvious idea for me to take up. So I wrote my REST API, used Jersey, and everything seemed to be working fine.

But then I checked out the cost of hosting a Java app on server, and then I decided to write the API in PHP. I thought that REST was basically just providing different URLs. But then I came across this tutorial here. In this tutorial, the author just makes call to normal PHP files, and that's it. I am echoing JSON encoded data in my PHP script, that I get back. This does not sound very RESTful to me. Maybe because I don't see /getClientInfo,addClientInfo kind of URLs.

Calling normal PHP scripts is just so normal. What did REST add to it?

  • 写回答

1条回答 默认 最新

  • dongnuo6310 2014-09-22 13:05
    关注

    In short: it does not matter. At all.

    The actual API here is an HTTP interface. The web server this all runs on is the API. You're just dressing it up differently by using different URLs or possibly different protocols on top of HTTP, e.g. SOAP or such. But fundamentally nothing changes, you're making an HTTP request and you're receiving data back in an HTTP response, period.

    REST is simply one way to structure your API's URL names and parameter conventions etc., and a way that makes sense in the context of HTTP. But it's not the only way and by itself REST doesn't do anything that's absolutely necessary or not doable any other way.

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

报告相同问题?