2017 © Pedro Peláez
 

library guzzle-stripbom-plugin

Plug-in for Guzzle that strips BOMs from server responses

image

cviebrock/guzzle-stripbom-plugin

Plug-in for Guzzle that strips BOMs from server responses

  • Tuesday, September 24, 2013
  • by cviebrock
  • Repository
  • 1 Watchers
  • 3 Stars
  • 112 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

guzzle-stripbom-plugin

Plug-in for Guzzle that strips BOMs from server responses., (*1)

Usage

In your project's composer.json file:, (*2)

    "require": {
        "cviebrock/guzzle-stripbom-plugin": "0.1.*",
    }

In your code:, (*3)

$client = new Guzzle\Http\Client('http://example.com');

$client->addSubscriber( new Cviebrock\Guzzle\Plugin\StripBom\StripBomPlugin() );

$request = $client->get('some/request');

$response = $client->send($request);

$data = $response->json();

Why?

Some API services (mostly .NET services) include a BOM in their response body. The BOM is 2-4 bytes that indicate what character encoding the response is in (e.g. UTF8). The problem is that PHP's json_decode() function and SimpleXML classes barf when trying to parse strings that include a BOM. If you are getting a "Can't parse JSON" error when handling a request, but it looks like JSON to you, this is likely what's happening., (*4)

This plugin strips those bytes off if they exist, before any JSON/XML parsing., (*5)

Kudos? Questions? Complaints?

Please use the issue tracker., (*6)

The Versions

24/09 2013

dev-master

9999999-dev https://github.com/cviebrock/guzzle-stripbom-plugin

Plug-in for Guzzle that strips BOMs from server responses

  Sources   Download

MIT

The Requires

 

plugin json xml guzzle bom

24/09 2013

dev-develop

dev-develop https://github.com/cviebrock/guzzle-stripbom-plugin

Plug-in for Guzzle that strips BOMs from server responses

  Sources   Download

MIT

The Requires

 

plugin json xml guzzle bom

24/09 2013

0.1.3

0.1.3.0 https://github.com/cviebrock/guzzle-stripbom-plugin

Plug-in for Guzzle that strips BOMs from server responses

  Sources   Download

MIT

The Requires

 

plugin json xml guzzle bom