requests for php(PHP开发工具)

requests for php(PHP开发工具)

官方

系统:Android

日期:2026-01-30

类别:电脑软件

版本:v2.0.8

  • 详情
  • 相关
  • 评论
    我得说,requests for php这个库真的挺让我惊喜的,它完全用PHP写的,没有任何依赖,安装和使用都特别方便,对于咱们开发者来说简直是福音。它支持各种HTTP请求方法,像GET、POST这些常用的操作都简化了很多,还能轻松处理头部信息、文件上传和国际域名,功能相当全面。我特别喜欢它那种“开箱即用”的感觉,不用折腾复杂的配置,直接就能集成到项目里去。虽然文章里提到它去掉了Python HTTP/1.1以外的一切工作,但我觉得这恰恰说明它专注且高效,非常适合PHP环境下的Web开发。从实际使用的角度看,无论是获取远程数据还是提交表单,requests都能让代码变得简洁明了,大大提升了开发效率,确实是个强大又好用的工具。

    requests是一个用PHP编写的HTTP库,遵循ISC开源协议,目前托管在GitHub上,该库去带了Python HTTP/1.1意外的一切工作,能够开发人员和Web服务无缝的结合在一起,该库没有任何的依赖关系,你可以独立在任何开发环境以外,也不需要相关的软件进行配置,安装方式也多种多样。

    你可以利用requests for php发送HEAD、GET、POST、PUT、DELETE和PATCH HTTP请求,并且简化了发送请求,使得用户能够简单的进行添加标题,表单数据,多部分文件和参数等等文件。其次该库还适用于国际域名、身份验证、自动压缩gzip压缩响应等。从中可以看出requests是一款非常好用且强大的托管HTTP请求的标签。

    requests for php如何使用:

    1、下载压缩后,得到如下文件

    把lipary目录重名称为requests,然后拷贝到程序的类库文件夹

    3、引用类库文件

    require_once ('requests/Requests.php');

    4、让程序自动引用相关内部类库(一定要执行这行代码)

    Requests::register_autoloader();

    5、开始使用GET或POST请求获取远程数据

    $response = Requests::get('https://github.com/timeline.json');

    var_dump($response);

    requests for php常用方法说明:

    1、使用GET发送请求获取远程数据 Requests::get($url, $headers = array(), $options = array());

    这里有3个参数可以使用

    第1个参数:$url 为需要获取远程数据的url链接,例如:

    $response = Requests::get('https://github.com/timeline.json');

    第2个参数:$headers = array() 为附加的头部请求

    array('Accept' => 'application/json')

    第3个参数:$options = array() 为配置参数

    `timeout`: 设置响应超时时间

    (integer, seconds, default: 10)

    `useragent`: 设置发送到服务器的用户代理

    (string, default: php-requests/$version)

    `follow_redirects`: 是否允许3XX重定向

    (boolean, default: true)

    `redirects`: How many times should we redirect before erroring?

    (integer, default: 10)

    `blocking`: Should we block processing on this request?

    (boolean, default: true)

    `filename`: File to stream the body to instead.

    (string|boolean, default: false)

    `auth`: Authentication handler or array of user/password details to use for Basic authentication

    (Requests_Auth|array|boolean, default: false)

    `proxy`: Proxy details to use for proxy by-passing and authentication

    (Requests_Proxy|array|boolean, default: false)

    `idn`: Enable IDN parsing

    (boolean, default: true)

    `transport`: Custom transport. Either a class name, or a transport object. Defaults to the first working transport from

    {@see getTransport()}

    (string|Requests_Transport, default: {@see getTransport()})

    `hooks`: Hooks handler.

    (Requests_Hooker, default: new Requests_Hooks())

    `verify`: Should we verify SSL certificates? Allows passing in a custom

    certificate file as a string. (Using true uses the system-wide root

    certificate store instead, but this may have different behaviour

    across transports.)

    (string|boolean, default: lipary/Requests/Transport/cacert.pem)

    `verifyname`: Should we verify the common name in the SSL certificate?

    (boolean: default, true)

    2、使用POST发送请求获取远程数据 Requests::post($url, $headers = array(), $data = array(), $options = array());

    这里有4个参数可以使用,多了一个请求数据(相当于表单提交的数据),其实get也有这个数据,get请求直接附加在url上了

    第1个参数:$url 同get的第一个参数

    第2个参数:$headers = array() 同get的第2个参数

    第4个参数:$options = array() 同get的第3个参数

    第3个参数:$data = array() 为表单提交的数据

    展开内容

    应用信息

    • 包名:
    • MD5:
    • 需要网络

    评分及评论

    4.5满分5.0分

    点击星星用来评分

    评论需审核后才能显示
    同类排行