gpt4 book ai didi

php - 推荐一个好的 PHP HTTP 类

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:04:03 26 4
gpt4 key购买 nike

对于我以前用过的项目

/**
* 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 类/库。

你用什么来实现这个功能?

最佳答案

PHP 有一个 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.

此外,大多数能够处理远程资源的 PHP 函数都可以与自定义一起使用 Stream Contexts ,这将允许您 configure how PHP connects to resources.

关于php - 推荐一个好的 PHP HTTP 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4659264/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com