Giter Club home page Giter Club logo

Comments (6)

mtdowling avatar mtdowling commented on April 28, 2024 2

Guzzle follows the PHP convention of suffixing duplicate parameter values with brackets containing an array index (e.g. ?q[0]=a&q[1]=b'

You can override this behavior by specifying a different aggregation function on the query string object owned by the request:

<?php
$client = new \Guzzle\Http\Client();
$request = $client->get("http://example.com/search?q=blah&facet=class&facet=property");
$request->getQuery()->setAggregateFunction(array($request->getQuery(), 'aggregateUsingDuplicates'));
$response = $request->send();

I'm committing a new query string aggregation function that will allow duplicate query string values in a URL. This should fix your issue.

from guzzle.

kevinohashi avatar kevinohashi commented on April 28, 2024 1

Was this removed at some point? How would one do it in Guzzle 7?

from guzzle.

mtdowling avatar mtdowling commented on April 28, 2024

The new aggregation method was added in commit f3a5b01

from guzzle.

elgeorge2k avatar elgeorge2k commented on April 28, 2024

Im having the same issue, the explanation is not satisfactory because this is what happen:

Fatal error: Call to undefined method Guzzle\Http\QueryString::setAggregateFunction()

I tried doing it with the setAggregator without much success:

$request = $client->get('http://www.google.com/?q=1&q=2');
$request->getQuery()->setAggregator(
    new Guzzle\Http\QueryAggregator\DuplicateAggregator()
);
echo $request->getQuery();

q%5B0%5D=1&q%5B1%5D=2

Adding ->useUrlEncoding(false); only makes it look prettier:

q[0]=1&q[1]=2

from guzzle.

mtdowling avatar mtdowling commented on April 28, 2024

How are they bring overwritten? When parsing a string, adding to the query, etc? Be sure to use the add method of the query string and not the set method.

Thanks,
Michael

On Jun 13, 2013, at 9:46 PM, Jorge Muñoz [email protected] wrote:

Im having the same issue, the explanation is not satisfactory because this is what happen:

Fatal error: Call to undefined method Guzzle\Http\QueryString::setAggregateFunction()
I tried doing it with the setAggregator without much success:

$request = $client->get('http://www.google.com/?q=1&q=2');
$request->getQuery()->setAggregator(
new Guzzle\Http\QueryAggregator\DuplicateAggregator()
);
echo $request->getQuery();
q%5B0%5D=1&q%5B1%5D=2

Adding ->useUrlEncoding(false); only makes it look prettier:

q[0]=1&q[1]=2


Reply to this email directly or view it on GitHub.

from guzzle.

untoreh avatar untoreh commented on April 28, 2024

what about posting parameters with same name?

from guzzle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.