Adding GET parameters to an HTTP request is
quite simple, and can be done either by specifying them as part of the URL, or by using
the setParameterGet() method.
This method takes the GET parameter's name as its first parameter,
and the GET parameter's value as its second parameter.
For convenience, the setParameterGet() method can also accept a
single associative array of name => value GET variables - which may
be more comfortable when several GET parameters need to be set.
Example 462. Setting GET Parameters
<?php
// Setting a get parameter using the setParameterGet method
$client->setParameterGet('knight', 'lancelot');
// This is equivalent to setting such URL:
$client->setUri('http://example.com/index.php?knight=lancelot');
// Adding several parameters with one call
$client->setParameterGet(array(
'first_name' => 'Bender',
'middle_name' => 'Bending'
'made_in' => 'Mexico',
));
While GET parameters can be sent with every request method, POST
parameters are only sent in the body of POST requests. Adding POST
parameters to a request is very similar to adding GET parameters,
and can be done with the setParameterPost() method, which is
similar to the setParameterGet() method in structure.
Example 463. Setting POST Parameters
<?php
// Setting a POST parameter
$client->setParameterPost('language', 'fr');
// Setting several POST parameters, one of them with several values
$client->setParameterPost(array(
'language' => 'es',
'country' => 'ar',
'selection' => array(45, 32, 80)
));
Note that when sending POST requests, you can set both GET and
POST parameters. On the other hand, while setting POST parameters
for a non-POST request will not trigger and error, it is useless.
Unless the request is a POST request, POST parameters are simply
ignored.




