duanci3845 2013-09-04 17:28
浏览 135

RESTful Api还是直接访问?

I'm asking this question because some of the websites is visited seems to be using a RESTful API to access the data even if it's on the website...

For example: my website will have 6 pages and 5 of them use the DB. But, I will also have a REST api for my partners...

So, the question is:

On my website, is it better to access directly the DB via mysqli_query or to use a RESTful API with Ajax calls to load data?

Just a note: I'll be using Zend Framework 2 for my RESTful API except if someone has a better option... I know Node.js and PHP... I'm able to write it in Ruby or something if it's better for me... Need a opinion on that...

  • 写回答

2条回答 默认 最新

  • duanmeng1862 2013-09-04 17:40
    关注

    Use the RESTful API.

    The specification of REST is that we use the HTTP methods, which he calls verbs.(GET, POST, PUT, DELETE).

    A direct request would be limiting it, or you would be using at most two method (verbs) - GET and POST.

    For that you have to do this:

    GET /user/frederick/edit
    GET /user/frederick/update
    GET /user/frederick/delete
    GET /user/new
    

    And with a RESTful API:

    GET /user/frederick/
    POST /user/new/
    PUT /user/frederick/
    DELETE /user/frederick/
    
    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?