Handle errors when querying qrzcq (i.e. non-premium)

This commit is contained in:
phl0
2024-11-25 14:33:05 +01:00
parent 6b573f360c
commit 888f9c9743
2 changed files with 14 additions and 6 deletions

View File

@@ -85,8 +85,13 @@ class Callbook {
}
if (!$this->ci->session->userdata('qrzcq_session_key')) {
$qrzcq_session_key = $this->ci->qrzcq->session($username, $password);
$this->ci->session->set_userdata('qrzcq_session_key', $qrzcq_session_key);
$result = $this->ci->qrzcq->session($username, $password);
if ($result[0] == 0) {
$this->ci->session->set_userdata('qrzcq_session_key', $result[1]);
} else {
$data['error'] = __("QRZCQ Error").": ".$result[1];
return $data;
}
}
$callbook = $this->ci->qrzcq->search($callsign, $this->ci->session->userdata('qrzcq_session_key'), $reduced);

View File

@@ -27,12 +27,15 @@ class Qrzcq {
// Create XML object
$xml = simplexml_load_string($xml);
if (isset($xml->Session->Error)) {
log_message('debug', 'Error: '.$xml->Session->Error);
if (isset($xml->Session->Key)) {
$result = array( 0, (string) $xml->Session->Key);
} else if (isset($xml->Session->Error)) {
$result = array( 1, (string) $xml->Session->Error);
} else {
$result = array( 2, 'Unknown error');
}
// Return Session Key
return (string) $xml->Session->Key;
return $result;
}
// Set Session Key session.