承接 cviebrock/guzzle-stripbom-plugin 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cviebrock/guzzle-stripbom-plugin

Composer 安装命令:

composer require cviebrock/guzzle-stripbom-plugin

包简介

Plug-in for Guzzle that strips BOMs from server responses

README 文档

README

Plug-in for Guzzle that strips BOMs from server responses.

Usage

In your project's composer.json file:

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

In your code:

$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.

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

Kudos? Questions? Complaints?

Please use the issue tracker.

统计信息

  • 总下载量: 434
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-09-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固