我打算编写一个 api,在试用了 facebook api 之后,我真的很喜欢他们做事的方式,尤其是他们使用的 url 方案。
例如,对于 facebook,您可以执行以下操作:
http://graph.facebook.com/me/friends
或类似的东西来获取用户个人资料的 friend 的 JSON 对象。
我知道如何使用查询字符串和诸如此类的东西,例如:
http://api.mysite.com/users.php?userid=...&feed=friends
这里有人知道我如何使用他们的 url 方案实现类似于 facebook api 的东西吗?我真的很喜欢它的流动方式(几乎具有类似 jQuery 的可链接性效果)。
我查找了 apache 的“mod_alias”模块,但无法确定这是否是我需要的...
谢谢!
最佳答案
Facebook 遵循 RESTful 架构模式。我建议您开始研究相同的架构。这是 wikipedia article作为定义。
Representational State Transfer (REST) is a style of software architecture for distributed hypermedia systems such as the World Wide Web. The term Representational State Transfer was introduced and defined in 2000 by Roy Fielding in his doctoral dissertation. Fielding is one of the principal authors of the Hypertext Transfer Protocol (HTTP) specification versions 1.0 and 1.1.
关于php - 如何实现类似 facebook 的 api?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6430048/