Building query string programmatically in Guzzle?

后端 未结 3 1643
轻奢々
轻奢々 2021-01-17 14:56

In my PHP Guzzle client code, I have something like

$c = new Client(\'http://test.com/api/1.0/function\');

$request = $c->get(\'?f=4&l=2&p=3&         


        
3条回答
  •  醉梦人生
    2021-01-17 15:22

    You can:

    $c = new Client('http://test.com/api/1.0/function');
    
    $request = $c->get();
    
    $q = $request->getQuery();
    
    $q->set('f', 4);
    $q->set('l', 2);
    $q->set('p', 3);
    $q->set('u', 5);
    

提交回复
热议问题