在smpplib Python上接收SMS的问题

时间:2019-10-10 17:43:27

标签: python smpp

在接收带有拉丁字符的SMS时出现问题,当我使用命令pdu.short_message.decode('utf-8')时,会修剪所有拉丁字符。有人知道如何解决吗?

硬件是具有启用了smpp服务器的goip4 我尝试使用python 3.6和3.7相同的问题

代码来自互联网,但与我在项目中使用的代码相同。

logging.basicConfig(level='DEBUG')
client = smpplib.client.Client('123.456.789.101', 1123)
def getPdu(pdu):
    print(pdu.short_message.decode('utf-8'))
client.set_message_received_handler(getPdu)
client.connect()
client.bind_transceiver(system_id='1234', password='5678')
parts, encoding_flag, msg_type_flag = smpplib.gsm.make_parts('Руский из питона 3, кодировочку зажги!\n')
for part in parts:
    pdu = client.send_message(
        source_addr_ton=smpplib.consts.SMPP_TON_NWSPEC,
        source_addr_npi=smpplib.consts.SMPP_NPI_ISDN,
        source_addr='1591',
        dest_addr_ton=smpplib.consts.SMPP_TON_NATNL,
        dest_addr_npi=smpplib.consts.SMPP_NPI_ISDN,
        # Make sure thease two params are byte strings, not unicode:
        destination_addr='79531498486',
        short_message=part,
        data_coding=encoding_flag,
        esm_class=msg_type_flag,
        registered_delivery=True,
    )
    print(pdu.sequence)
client.listen()

0 个答案:

没有答案