Esempio n. 1
0
 public function getCnis($key)
 {
     if (!is_string($key)) {
         throw new tmchException("Key must be filled when requesting CNIS information");
     }
     if (is_null(parent::getHostname()) || parent::getHostname() == '') {
         throw new tmchException("Hostname must be set when requesting CNIS information");
     }
     $url = "https://" . parent::getHostname() . "/" . $key . ".xml";
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_USERPWD, parent::getUsername() . ":" . parent::getPassword());
     curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     if (curl_errno($ch)) {
         throw new tmchException(curl_error($ch));
     }
     $output = curl_exec($ch);
     if (strlen($output) == 0) {
         throw new tmchException("Empty output received from CNIS service");
     }
     $this->setLastInfo(curl_getinfo($ch));
     curl_close($ch);
     if (strpos($output, '404 Not Found') !== false) {
         throw new tmchException("Requested URL was not found on this server");
     }
     $result = new tmchClaimData();
     $result->loadXML($output);
     $result->setClaims();
     return $result;
 }
Esempio n. 2
0
 public function getDnl()
 {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, parent::getHostname());
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_USERPWD, parent::getUsername() . ":" . parent::getPassword());
     curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     $output = curl_exec($ch);
     if (curl_errno($ch)) {
         throw new tmchException(curl_error($ch));
     }
     $this->setLastinfo(curl_getinfo($ch));
     curl_close($ch);
     return explode("\n", $output);
 }