1

My web development experience has mostly been setting up a CMS like Wordpress or Drupal and creating custom themes. Actually work in server-size coding has been very minimal. I've played around with php a little, trying to mod off of phpBB and beginning to learn some MVC work with CodeIgniter. Overall, this seems like a pretty big step forward, but it's something I need (I think) to do for a project I am working on.

Essentially what I want to do is have a service like Twitter of Facebook (not in the social networking sense); a user is able to log into the site and perform various operations, while also being able to use an android application that supports limited operations.

After some Googling and reading articles on the internet, it appears REST is the way to go. But I can't quite seem to grasp some of the technical details. I understand how the HTTP Request/Response works, but I don't know how I can code everything server side so that visiting example.com/item/1 will bring up the details of item 1 in the browser and can also perform a GET Request in my Android app so it can grab the details from the database and display in on the site.

Any suggested readings or some tips on how to execute this?

4

1 回答 1

0

您可以使用 MVC 来实现这一点。默认情况下,让控制器向模型询问项目的详细信息,然后将信息传递给视图。对您想要接受的每种类型的请求(例如 POST、PUT 等)重复此过程,您在控制器中定义一个新函数,要求模型执行相应的数据库操作,并将响应返回给视图。

这里有使用 CodeIgniter 启动和运行 REST 服务器的有用教程

于 2012-06-03T07:17:39.783 回答