# Sign the query using the private key query = rs_private_key + urlencode(data)
# Encode the string to bytes for hashing query = query.encode('utf-8')
# Hash the private key and query sign = hashlib.sha256() sign.update(query)
# Initialize the pycurl object c = pycurl.Curl()
# This part simply replicates the GET query string to be POSTed as a single 'query' POST item. postdata = [ ('query', data), ('sign', sign.hexdigest()), ('user', rs_user), ('file', (c.FORM_FILE, file_path)) # IMPORTANT: this wasn't part of the signature! ] postdata = urlencode(postdata)