Zend_Http_Client::setParameterPost PHP Method

setParameterPost() public method

Set a POST parameter for the request. Wrapper around _setParameter
public setParameterPost ( string | array $name, string $value = null ) : Zend_Http_Client
$name string | array
$value string
return Zend_Http_Client
    public function setParameterPost($name, $value = null)
    {
        if (is_array($name)) {
            foreach ($name as $k => $v) {
                $this->_setParameter('POST', $k, $v);
            }
        } else {
            $this->_setParameter('POST', $name, $value);
        }
        return $this;
    }

Usage Example

 private function getSintegraHtmlData($num_cnpj, $proxy = '', $url = 'http://www.sintegra.es.gov.br/resultado.php')
 {
     try {
         // Configurações da conexão HTTP com a página
         $zendHttpConfig = array('adapter' => 'Zend_Http_Client_Adapter_Socket', 'ssltransport' => 'tls', 'timeout' => 15);
         if (is_array($proxy)) {
             $zendHttpConfig['proxy_host'] = $proxy['HOST'];
             $zendHttpConfig['proxy_port'] = $proxy['PORT'];
         }
         // Criar o objeto que fara a requisição HTTP
         $zendHttpClient = new Zend_Http_Client($url);
         $zendHttpClient->setConfig($zendHttpConfig);
         // Definir os parâmetros POST enviados a página
         // Obs: O parâmetro "botao" é obrigatório
         $zendHttpClient->setParameterPost('num_cnpj', $num_cnpj);
         $zendHttpClient->setParameterPost('botao', 'Consultar');
         // Fazer requisição da página (método POST)
         $response = $zendHttpClient->request(Zend_Http_Client::POST);
         // Retornar o corpo da página
         if ($response->isError()) {
             throw new Exception($response->getStatus());
         } else {
             return $response->getBody();
         }
     } catch (Exception $e) {
         $erro = $e->message;
         die("Erro ao buscar informações no Sintegra. Erro: " . $erro);
     }
 }
All Usage Examples Of Zend_Http_Client::setParameterPost