首页 > 电脑软件 > requests for php(PHP开发工具) v2.0.8

requests for php(PHP开发工具)

v2.0.8

  • 软件大小:226K
  • 软件版本:v2.0.8
  • 软件类型:国产软件
  • 软件分类:电脑软件
  • 软件语言:简体中文
  • 更新时间:2026-01-30
  • 安全检测:无插件360通过腾讯通过金山通过瑞星通过小红伞通过

  • 软件评分:

普通下载

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

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() 为表单提交的数据

网友评论

共有 0条评论

captcha 评论需审核后才能显示

应用推荐

游戏推荐