在Guzzle中的POST请求中禁用urlencode [英] Disable urlencode in POST request in Guzzle

查看:212
本文介绍了在Guzzle中的POST请求中禁用urlencode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试发布一些数据,而Guzzle会自动urlencode()发布所有值.我要禁用它,因为它的行为很奇怪(Enter字符有问题).我搜索了文档,找到了关于此的参考

I am trying to post some data and Guzzle automatically urlencode() all post values. I want to disable it because its acting weird (There is a problem with the Enter character). I searched the documentation and found a reference about this

$query->useUrlEncoding(false);

但有关GET请求.

文档还说:可以通过传递false来禁用URL编码,通过传递true来启用URL编码,通过传递Query :: FORM_URLENCODED来设置为使用RFC 1738(内部使用PHP的urlencode函数),或者通过传递Query来设置为RFC 3986: :RFC_3986(这是默认设置,内部使用PHP的rawurlencode函数)."

Also documentation says : "URL encoding can be disabled by passing false, enabled by passing true, set to use RFC 1738 by passing Query::FORM_URLENCODED (internally uses PHP's urlencode function), or set to RFC 3986 by passing Query::RFC_3986 (this is the default and internally uses PHP's rawurlencode function)."

有什么想法吗?

推荐答案

对于那些看上去很酷的人来说,Guzzle已被完全重写&文档还不是100%

For those looking, Guzzle has been completely rewritten & the docs are not yet 100%

该方法现在位于Query对象上,并且可以将其设置为:

The method is now on the Query object, and can be set like:

$ request-> getQuery()-> setEncodingType(false);

$request->getQuery()->setEncodingType(false);

这篇关于在Guzzle中的POST请求中禁用urlencode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆