Guest User

Untitled

a guest
May 8th, 2018
889
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. #Python SMS API:
  2.  
  3. from smsapi import SmsApi
  4. username = "USERNAME"
  5. password = "PASSWORD"
  6.  
  7. sms = SmsApi(username, password)
  8.  
  9. total_points = sms.get_points()['points']
  10. print("You have", total_points, "points left")
  11.  
  12. import sqlite3
  13. myDB = sqlite3.connect("Clients.db")
  14. dbCursor = myDB.cursor()
  15.  
  16. list_of_client_numbers = dbCursor.execute('''SELECT mobNumber FROM clientsTable''')
  17.  
  18. for eachRecord in list_of_client_numbers:
  19. sms = sms.send_sms(
  20. recipient=eachRecord,
  21. sender_name="YOUR COMPANY NAME",
  22. message="MESSAGE",
  23. eco=False)
  24.  
  25. myDB.close()
  26.  
  27. total_points = sms.get_points()['points']
  28. print("You have", total_points, "points left")
  29.  
  30. sms = sms.send_sms(
  31.  
  32. recipient="91902000xxxx",
  33.  
  34. message="test message"
  35. )
  36.  
  37. from __future__ import print_function
  38. import time
  39. import karix
  40. from karix.rest import ApiException
  41. from karix.configuration import Configuration
  42. from karix.api_client import ApiClient
  43. from pprint import pprint
  44.  
  45. # Configure HTTP basic authorization: basicAuth
  46. config = Configuration()
  47. config.username = 'YOUR_USERNAME'
  48. config.password = 'YOUR_PASSWORD'
  49. # create an instance of the API class
  50. api_instance = karix.MessageApi(api_client=ApiClient(configuration=config))
  51. message = karix.CreateMessage(source="<source>", destination=["<destination>"], text="Sent from python SDK")
  52.  
  53. try:
  54. api_response = api_instance.send_message(message=message)
  55. pprint(api_response)
  56. except ApiException as e:
  57. print("Exception when calling MessageApi->send_message: %sn" % e)
Add Comment
Please, Sign In to add comment