本文介绍了将查询字符串参数添加到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请求中?
发布评论