将查询字符串参数添加到Guzzle GET请求中?

编程入门 行业动态 更新时间:2024-10-28 02:30:24
本文介绍了将查询字符串参数添加到Guzzle GET请求中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我阅读了此答案,但我相信有更好的方法在Guzzle中创建一个http url查询,我正在寻找类似的东西,但是无法使其正常工作,也不知道是否有一种方法可以转储url字符串以查看其是否正确处理.有人可以告诉我正确的方法吗?

I read this answer but I believe there is a better way to create a http url query in Guzzle, I am looking for something like this, but cannot get it to work correctly, nor do I know if there is a way to dump the url string to see if it is processing correctly. Could someone show me the correct way to do this?

// works correctly $client = New GuzzleHttp\Client(); $request = $client->get('192.168.50.8/foo?-db=database&-lay=layout&-find'); print_r($request->getBody());

不起作用

$request = $client->get($config->Layout['server'], [], [ 'query' => [ $config->Layout['switches'], // ([ '-db' => 'database', '-lay' => 'layout', '-find' => true) $config->Layout['options'], // other params ] ]);

推荐答案

我有同样的问题.我找到了解决办法

I have the same problem. I found solution

public static function getGroupList($current=false) { $response = self::getRestClient()->get( [ 'domains/{domainId}/pricelists', ['domainId' => self::getDomainId()] ], [ 'query' => [ current => $current ] ] ); return new RestResponse($response);

尝试

$response = $client->get( [ $config->Layout['server'], [] ], [ 'query' => [ $config->Layout['switches'], // ([ '-db' => 'database', '-lay' => 'layout', '-find' => true) $config->Layout['options'], // other params ] ] );

更多推荐

将查询字符串参数添加到Guzzle GET请求中?

本文发布于:2023-10-12 17:41:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1485416.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   参数   Guzzle

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!