【发布时间】:2012-02-15 21:34:56
【问题描述】:
我可能不应该使用 file_get_contents() 我应该使用什么?我想保持简单。
警告:file_get_contents(http://en.wikipedia.org/w/api.php?action=query&titles=Your_Highness&prop=revisions&rvprop=content&rvsection=0):打开流失败:HTTP 请求失败! HTTP/1.0 403 禁止
【问题讨论】:
-
您可以使用 file_get_contents 来完成,但如果您喜欢它简单,请改用 cURL,因为您需要按照 API documentation 中的描述处理 cookie。 PHP native 和 cURL 方式都可以,但 cURL 更简单。
-
比 cURL 更好的是 HTTP_Request2,你可以通过 Pear 下载它,这是一个更好的体验,因为它是一个合适的 OO 库
-
@netcoder,只有你想登录才需要处理cookies。不是只需要访问它。
标签: php file-get-contents wikipedia-api