Guzzle is a PHP HTTP client that makes it easy to work with HTTP/1.1 and takes the pain out of consuming web services.

  • Pluggable HTTP adapters that can send requests serially or in parallel
  • Doesn't require cURL, but uses cURL by default
  • Streams data for both uploads and downloads
  • Provides event hooks & plugins for cookies, caching, logging, OAuth, mocks, etc...
  • Keep-Alive & connection pooling
  • SSL Verification
  • Automatic decompression of response bodies
  • Streaming multipart file uploads
  • Connection timeouts
$client = new GuzzleHttp\Client();
$res = $client->get('https://api.github.com/user', [
'auth' => ['user', 'pass']
]);
echo $res->getStatusCode(); // 200
echo $res->getHeader('content-type'); // 'application/json; charset=utf8'
echo $res->getBody(); // {"type":"User"...'
var_export($res->json()); // Outputs the JSON decoded data

User guide

HTTP Components

There are a number of optional libraries you can use along with Guzzle's HTTP layer to add capabilities to the client.

Log Subscriber
Logs HTTP requests and responses sent over the wire using customizable log message templates.
OAuth Subscriber
Signs requests using OAuth 1.0.
Progress Subscriber
Emits progress events when uploading and downloading data.
Cache Subscriber
Implements a private transparent proxy cache that caches HTTP responses.
Retry Subscriber
Retries failed requests using customizable retry strategies (e.g., retry based on response status code, cURL error codes, etc...)
Message Integrity Subscriber
Verifies the message integrity of HTTP responses using customizable validators. This plugin can be used, for example, to verify the Content-MD5 headers of responses.

Service Description Commands

You can use the Guzzle Command library to encapsulate interaction with a web service using command objects. Building on top of Guzzle's command abstraction allows you to easily implement things like service description that can be used to serialize requests and parse responses using a meta-description of a web service.

Guzzle Command
Provides the foundational elements used to build high-level, command based, web service clients with Guzzle.
Guzzle Services
Provides an implementation of the Guzzle Command library that uses Guzzle service descriptions to describe web services, serialize requests, and parse responses into easy to use model structures.

Guzzle php resetful webservice farmework的更多相关文章

  1. WebService-axis2

    WebService框架有好多,常用的cxf,axis2等,axis2的配置过程相对简单,不用编写接口,在实现.只需要一个Service服务类即可.配置过程大致如下: 1,导入jar包(这里我是把ax ...

  2. 如何从40亿整数中找到不存在的一个 webservice Asp.Net Core 轻松学-10分钟使用EFCore连接MSSQL数据库 WPF实战案例-打印 RabbitMQ与.net core(五) topic类型 与 headers类型 的Exchange

    如何从40亿整数中找到不存在的一个 前言 给定一个最多包含40亿个随机排列的32位的顺序整数的顺序文件,找出一个不在文件中的32位整数.(在文件中至少确实一个这样的数-为什么?).在具有足够内存的情况 ...

  3. webService

    什么是webService WebService,顾名思义就是基于Web的服务.它使用Web(HTTP)方式,接收和响应外部系统的某种请求.从而实现远程调用.  1:从WebService的工作模式上 ...

  4. 开始webservice了

    一.WebService到底是什么 一言以蔽之:WebService是一种跨编程语言和跨操作系统平台的远程调用技术. 所谓跨编程语言和跨操作平台,就是说服务端程序采用java编写,客户端程序则可以采用 ...

  5. Spring WebService入门

    Web service是一个平台独立的,低耦合的,自包含的.基于可编程的web的应用程序,可使用开放的XML(标准通用标记语言下的一个子集)标准来描述.发布.发现.协调和配置这些应用程序,用于开发分布 ...

  6. 浅谈跨域以及WebService对跨域的支持

    跨域问题来源于JavaScript的同源策略,即只有 协议+主机名+端口号 (如存在)相同,则允许相互访问.也就是说JavaScript只能访问和操作自己域下的资源,不能访问和操作其他域下的资源. 在 ...

  7. 浅谈WebService的版本兼容性设计

    在现在大型的项目或者软件开发中,一般都会有很多种终端, PC端比如Winform.WebForm,移动端,比如各种Native客户端(iOS, Android, WP),Html5等,我们要满足以上所 ...

  8. Atitit webservice发现机制 WS-Discovery标准的规范attilax总结

    Atitit webservice发现机制 WS-Discovery标准的规范attilax总结 1.1. WS-Discovery标准1 1.2. 一.WS-Discovery1 1.2.1.   ...

  9. java调用CXF WebService接口的两种方式

    通过http://localhost:7002/card/services/HelloWorld?wsdl访问到xml如下,说明接口写对了. 2.静态调用 // 创建WebService客户端代理工厂 ...

随机推荐

  1. Jenkins api java 调用

    String filepath = "E:\\config.xml"; HttpClient client = new DefaultHttpClient(); HttpPost ...

  2. MYSQL数据库命名与其设计规范

    你是否对获得MYSQL数据库命名与其设计规范 的实际操作感到十分头疼?如果是这样子的话,以下的文章将会给你相应的解决方案,以下的文章主要是介绍获得MYSQL数据库命名与其设计规范 的方案,以下就是相关 ...

  3. Android学习手记(5) 基本UI布局

    1.View和ViewGroup Activity是Android应用程序的基本管理单元,Android的每一个窗口都是通过一个Activity来定义的,但是Activity并不能直接用来显示窗口.我 ...

  4. CentOS 6.4搭建zabbix

    系统环境:CentOS 6.4 64bit Zabbix版本:zabbix 2.2.3 前提条件:已安装好LNMP环境 一.服务端: 1.  下载zabbix安装包zabbix-2.2.3.tar.g ...

  5. 微信公众平台开发(一) ——实现URL接入

    一.填写服务器配置 登录微信公众平台,点击开发者中心,点击“修改配置”按钮,填写服务器地址(URL).Token和EncodingAESKey.URL是开发者用来接收微信消息和事件的接口URL.Tok ...

  6. HTTP Content-type 对照表

    文件扩展名 Content-Type(Mime-Type) 文件扩展名 Content-Type(Mime-Type) .*( 二进制流) application/octet-stream .tif ...

  7. Android 用ListView实现GridView分列显示

    我想实现百度影音首页的这种效果: 在网上用ScrollView+GridView可以实现,但是touch scrollview的时候会莫名刷新gridview,这样用户体验很不好,而且感觉百度不是这样 ...

  8. Oracle Union All 排序

    在oracle中使用union all或者 union 对两个结果集进行并集操作时,如果需要对查询结果集进行排序时,不能直接在后面加order by + 表字段 来排序 例如: 在oracle的soc ...

  9. vim编辑器中撤销和恢复操作

    在VIM编辑器下切换至命令行模式: 撤销: u 恢复: ctrl + r

  10. 11061160顾泽鹏homework-01

    我的Github地址是buaa11061160 教材:中文版 代码大全 (第二版) 斯蒂夫·迈克康奈尔 设计思路: 输入了一串数组a[0].a[1]..... 从a[0]开始向后扫,在以数字a[i]结 ...