php - 如何实现类似 facebook 的 api?

标签 php json facebook apache api

我打算编写一个 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/

相关文章:

java - 与 Java 和 PHP 兼容的密码散列

android - Json 字符串到 Realm 对象,最快的方法

javascript - 获取数组内部的数组

android - 如何在 Android 中获取 facebook 好友的生日、电子邮件和个人资料图片

php - 我只需要从另一个 html/php 页面导入表格

php - Wordpress 元查询搜索

javascript - Google Apps 爸爸笑话脚本 - JSON 解析错误 "Unexpected token: < "

android - Ionic2 和 Facebook 登录 : Errors in emulating android device after installing cordova-plugin-facebook4

php - 在 Facebook 帖子中标记他人?

php - 验证输入是否采用此时间格式 - "HH:MM"