AnsweredAssumed Answered

API V2.0 usage

Question asked by PeterPeter on Dec 7, 2011
Latest reply on Dec 27, 2011 by Eric Perraudeau

Hello all,

 

I just wanted to know if it is possible to make requests to the QualysGuard API through a proxy?

 

Because for the moment, I use the following code to get the header back with the authentication cookie to use :

 

 

<?php
$login = 'login'; // Qualys login $password = 'passwd'; // Qualys password $headers = array('X-Requested-With: Test'); $post = 'action=login&username='.$login.'password='.$password; // POST data $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://qualysguard.qualys.com/api/2.0/fo/session/'); curl_setopt($ch, CURLOPT_POST, 3); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); curl_setopt($ch, CURLOPT_PROXY, 'http://proxy.site.com:8080'); curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'login:passwd'); // Proxy account curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // Have to use this else the SSL won't work curl_setopt($ch, CURLOPT_HEADER, 1); // Get the header response back curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $data = curl_exec($ch); var_dump($data); curl_close($ch); ?>

 

 

The problem is that I get the header only of the proxy back. Is there an easier way to proceed or am I simply doing everything something wrong?

 

Regards,

Peter

Outcomes