I'm using an API using a POST request and Zend_Http_Client.
I need the query string to emulate a get request that would look like ?id=5&id=10&fileName=Sample-Document
. As you can see, there are two id parameters. Is there a way to do this using Zend_Http_Client and a $_POST request?
This is my code thusfar:
$client = new Zend_Http_Client();
.
..
... $client->config stuff goes here
..
.
$data = array('id'=>array('5', '10')), 'fileName'=>'Sample-Document');
$client->setParameterPost($data['fileName'], 'fileName');
// theoretically, i'd like to do it like this, but it doesn't work since i think the second line overwrites the first
$client->setParameterPost('id', ($data['id'][0]);
$client->setParameterPost('id', $data['id'][1]);
$client->request('POST');
I think setParameterPost takes the key as the first argument and the value as the second. See the source code: https://github.com/zendframework/zf1/blob/master/library/Zend/Http/Client.php
public function setParameterPost($name, $value = null)
However to pass multiple IDs through you could do it as an array. Try this:
$client->setParameterPost('id[0]', $data['id'][0]);
$client->setParameterPost('id[1]', $data['id'][1]);