FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Update README.md · python-smpplib/python-smpplib@fd8a175 · GitHub

Commit fd8a175

Browse files
Konstantin Podshumok
committed
Update README.md
some docs
1 parent c32ee04 commit fd8a175

1 file changed

Lines changed: 50 additions & 1 deletion

File tree

‎README.md‎

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,53 @@
11
python-libsmpp
22
==============
33

4-
SMPP library for Python
4+
SMPP library for Python
5+
6+
Example:
7+
```python
8+
import logging
9+
import sys
10+
11+
import smpplib.gsm
12+
import smpplib.client
13+
import smpplib.consts
14+
15+
# if you want to know what's happening
16+
logging.basicConfig(level='DEBUG')
17+
18+
parts, encoding_flag, msg_type_flag = smpplib.gsm.make_parts(u'Привет мир!\n'*10) # Two parts, UCS2, SMS with UDH
19+
20+
client = smpplib.client.Client('example.com', SOMEPORTNUMBER)
21+
22+
# Print when obtain message_id
23+
client.set_message_sent_handler(lambda pdu: sys.stdout.write('sent {} {}\n'.format(pdu.sequence, pdu.message_id)))
24+
client.set_message_received_handler(lambda pdu: sys.stdout.write('delivered {}\n'.format(pdu.receipted_message_id)))
25+
26+
client.connect()
27+
client.bind_transceiver(system_id='login', password='secret')
28+
29+
for part in parts:
30+
pdu = client.send_message(
31+
source_addr_ton=smpplib.consts.SMPP_TON_INTL,
32+
#source_addr_npi=smpplib.consts.SMPP_NPI_ISDN,
33+
source_addr='SENDERPHONENUM',
34+
dest_addr_ton=smpplib.consts.SMPP_TON_INTL,
35+
#dest_addr_npi=smpplib.consts.SMPP_NPI_ISDN,
36+
destination_addr='PHONENUMBER',
37+
short_message=part,
38+
data_coding=encoding_flag,
39+
esm_class=msg_type_flag,
40+
registered_delivery=True,
41+
)
42+
print(pdu.sequence)
43+
client.listen()
44+
```
45+
You also may want to listen in a thread:
46+
```python
47+
from threading import Thread
48+
t = Thread(target=client.listen)
49+
t.start()
50+
```
51+
52+
53+

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL