Feb 14, 2013

Zend: Authenticating into server

Since, setAuth still not working. I rather manually set the parameter to the cURl.

$config = array(
    'maxredirects' => 3, // By defualt Zend_Http_Client use 5 max redirect
    'timeout'   => 500,
    //'adapter'   => 'Zend_Http_Client_Adapter_Curl',
);

$url = 'YOUR_URL_ADDRESS';

$client = new  Zend_Http_Client($url, $config);
$client->setAdapter('Zend_Http_Client_Adapter_Curl');
//$client->setAuth($this->_user, $this->_pass); // Since seems not working I use
$client->setParameterPost(array(
    'skuId' => $skuId,
    'username' => $this->_user,
    'password' => $this->_pass,
)); 

$client->getAdapter()
        ->setCurlOption(CURLOPT_USERPWD, $this->_user.':'.$this->_pass)
       ->setCurlOption(CURLOPT_HTTPAUTH, CURLAUTH_ANY)
       ->setCurlOption(CURLOPT_SSL_VERIFYPEER, false)
       ->setCurlOption(CURLOPT_RETURNTRANSFER, 1)
       ->setCurlOption(CURLOPT_POST, 1)
;
$this->_response = $client->request("POST");

No comments: