diff --git a/qrzlogger.py b/qrzlogger.py index 4bcd281..4de6f1f 100644 --- a/qrzlogger.py +++ b/qrzlogger.py @@ -229,23 +229,21 @@ def queryQSOData(qso): # QRZ.com logbook entry via the API def sendQSO(qso): - insert = { 'KEY' : config['qrzlogger']['api_key'], 'ACTION' : 'INSERT', 'ADIF' : - '' + qso['band'][1] + - '' + qso['mode'][1] + - '' + call + - '' + qso['qso_date'][1] + - '' + config['qrzlogger']['station_call'] + - '' + qso['time_on'][1] + - '' + qso['rst_rcvd'][1] + - '' + qso['rst_sent'][1] + - '' + qso['tx_pwr'][1] + - '' + qso['comment'][1] + - ''} - print(insert) + # construct ADIF QSO entry + adif = '' + config['qrzlogger']['station_call'] + adif += '' + call + for field in qso: + adif += '<' + field + ':' + str(len(qso[field][1])) + '>' + qso[field][1] + adif += '' - data = urllib.parse.urlencode(insert) - #print(data) - #resp = requests.post(config['qrzlogger']['api_url'], data=insert) + # construct POST data + post_data = { 'KEY' : config['qrzlogger']['api_key'], 'ACTION' : 'INSERT', 'ADIF' : adif } + + print(post_data) + + # URL encode the payload + data = urllib.parse.urlencode(post_data) + # send the POST request to QRZ.com resp = requests.post(config['qrzlogger']['api_url'], headers=headers, data=data) #str_resp = resp.content.decode("utf-8")