建议一个好的PHP HTTP类(Recommendations for a good PHP HTTP class)

对于我之前使用过的项目

/** * HTTP Class * * This is a wrapper HTTP class that uses either cURL or fsockopen to * harvest resources from web. This can be used with scripts that need * a way to communicate with various APIs who support REST. * * @author Md Emran Hasan <phpfour@gmail.com> * @package HTTP Library * @copyright 2007-2008 Md Emran Hasan * @link http://www.phpfour.com/lib/http * @since Version 0.1 */

这很有效,但似乎并没有在一段时间内更新(事实上,上面的链接现在甚至不能工作......)。

我的最新项目将大量使用http方法(访问跨域和内部API),所以我需要确保尽可能高效地使用http类/库。

你使用这个功能是什么?

For previous projects I have used

/** * HTTP Class * * This is a wrapper HTTP class that uses either cURL or fsockopen to * harvest resources from web. This can be used with scripts that need * a way to communicate with various APIs who support REST. * * @author Md Emran Hasan <phpfour@gmail.com> * @package HTTP Library * @copyright 2007-2008 Md Emran Hasan * @link http://www.phpfour.com/lib/http * @since Version 0.1 */

This works very well but does not appear to have been updated in quite some time (indeed, the link above does not even work now...).

My latest project is going to make heavy use of http methods (accessing cross domain and internal APIs) so I need to make sure I am using as efficient an http class/library as possible.

What do you use for this functionality?

最满意答案

PHP 在PECL中有一个本地HTTP类 :

HTTP扩展简化了HTTP上下文(传入和传出)中HTTP URL,日期,重定向,标题和消息的处理。 它还提供了客户端首选语言和字符集协商的方法,以及通过缓存和恢复功能交换任意数据的便捷方式。

还提供了一个功能强大的请求和并行接口(PHP5 +),如果扩展名是使用cURL支持构建的。

此外,大多数能够使用远程资源的PHP函数都可以与自定义流上下文一起使用,这将允许您配置PHP连接资源的方式。

PHP has a native HTTP class in PECL:

The HTTP extension eases handling of HTTP URLs, dates, redirects, headers and messages in a HTTP context (both incoming and outgoing). It also provides means for client negotiation of preferred language and charset, as well as a convenient way to exchange arbitrary data with caching and resuming capabilities.

Also provided is a powerful request and parallel interface (PHP5+), if the extension is built with cURL support.

In addition, most PHP functions able to work with remote resources can be used with custom Stream Contexts, which will allow you to configure how PHP connects to resources.

建议一个好的PHP HTTP类(Recommendations for a good PHP HTTP class)

对于我之前使用过的项目

/** * HTTP Class * * This is a wrapper HTTP class that uses either cURL or fsockopen to * harvest resources from web. This can be used with scripts that need * a way to communicate with various APIs who support REST. * * @author Md Emran Hasan <phpfour@gmail.com> * @package HTTP Library * @copyright 2007-2008 Md Emran Hasan * @link http://www.phpfour.com/lib/http * @since Version 0.1 */

这很有效,但似乎并没有在一段时间内更新(事实上,上面的链接现在甚至不能工作......)。

我的最新项目将大量使用http方法(访问跨域和内部API),所以我需要确保尽可能高效地使用http类/库。

你使用这个功能是什么?

For previous projects I have used

/** * HTTP Class * * This is a wrapper HTTP class that uses either cURL or fsockopen to * harvest resources from web. This can be used with scripts that need * a way to communicate with various APIs who support REST. * * @author Md Emran Hasan <phpfour@gmail.com> * @package HTTP Library * @copyright 2007-2008 Md Emran Hasan * @link http://www.phpfour.com/lib/http * @since Version 0.1 */

This works very well but does not appear to have been updated in quite some time (indeed, the link above does not even work now...).

My latest project is going to make heavy use of http methods (accessing cross domain and internal APIs) so I need to make sure I am using as efficient an http class/library as possible.

What do you use for this functionality?

最满意答案

PHP 在PECL中有一个本地HTTP类 :

HTTP扩展简化了HTTP上下文(传入和传出)中HTTP URL,日期,重定向,标题和消息的处理。 它还提供了客户端首选语言和字符集协商的方法,以及通过缓存和恢复功能交换任意数据的便捷方式。

还提供了一个功能强大的请求和并行接口(PHP5 +),如果扩展名是使用cURL支持构建的。

此外,大多数能够使用远程资源的PHP函数都可以与自定义流上下文一起使用,这将允许您配置PHP连接资源的方式。

PHP has a native HTTP class in PECL:

The HTTP extension eases handling of HTTP URLs, dates, redirects, headers and messages in a HTTP context (both incoming and outgoing). It also provides means for client negotiation of preferred language and charset, as well as a convenient way to exchange arbitrary data with caching and resuming capabilities.

Also provided is a powerful request and parallel interface (PHP5+), if the extension is built with cURL support.

In addition, most PHP functions able to work with remote resources can be used with custom Stream Contexts, which will allow you to configure how PHP connects to resources.