I can't figure out what exactly I can do with $parameter when I use these methods.

Can I somehow use this parameter for sending custom headers?

Comments

voxpelli’s picture

The $parameter variable is for query parameters - those parameters that are part of the url - eg. "name" in "http://example.com/?name=123".

To add headers you would need to create the HttpClientRequest object yourself - the get(), post() etc are just shortcuts for creating a HttpClientRequest object and executing it in the HttpClient object.

This is probably how you should create a HttpClientRequest:

$client->execute(new HttpClientRequest($url, array(
  'method' => 'GET',
  'parameters' => $parameters,
  'headers' => array(
    'header-name' => 'header-value',
  ),
))));
vaidik’s picture

Status: Active » Closed (fixed)

Well this is what I was doing and it worked!

I was sort of sure that get(), post(), etc. would not be able to do this. Still confirmed it.