Пример #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;
 }
 /**
  * Retrieves standard claim info from TMCH via db.claimnotification.info (Key Systems site)
  * @param string $key
  * @return tmchClaimData
  * @throws tmchException
  */
 public function getCnis($key)
 {
     if (!is_string($key)) {
         throw new tmchException("Key must be filled when requesting CNIS information");
     }
     $url = "http://db.claimnotification.info?token=" . urlencode($key);
     if ($this->logging) {
         echo "Calling interface {$url}\n\n";
     }
     $output = file_get_contents($url);
     if (strlen($output) == 0) {
         throw new tmchException("Empty output received from CNIS service");
     }
     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;
 }