| Server IP : 209.209.40.120 / Your IP : 216.73.217.112 Web Server : Microsoft-IIS/10.0 System : Windows NT NEWWWW 10.0 build 17763 (Windows Server 2019) i586 User : NEWWWW$ ( 0) PHP Version : 8.3.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/HostingSpaces/admin/old247sms.co.uk/247sms.co.uk/wwwroot/clicksend/ |
Upload File : |
from __future__ import print_function
import time
from datetime import datetime
import os
import ast
import mysql.connector
import clicksend_client
from clicksend_client import SmsMessage
from clicksend_client.rest import ApiException
# Configure HTTP basic authorization: BasicAuth
configuration = clicksend_client.Configuration()
configuration.username = 'jackson@tickwaves.co.uk'
configuration.password = 'A278C4D0-43F0-84DA-4C87-D8CF2A3C8948'
# Create an instance of the API class
api_instance = clicksend_client.SMSApi(clicksend_client.ApiClient(configuration))
os.system("cls")
try:
while True:
mydb = mysql.connector.connect(
host="localhost",
user="smsEngine",
password="guEnaR28T",
database="smartsmsrouter"
)
mycursor = mydb.cursor()
current_time_screen= datetime.now().strftime("%Y-%m-%d %H:%M:%S")
current_time= datetime.now().strftime("%Y-%m-%d %H:%M")
print("Send Message Power by ClickSend",current_time_screen,sep=' ', end=" ")
#mycursor.execute("SELECT sn,bookname,messtype,datedue FROM schedule where username ='system' and domain='247sms.com' and status ='2'")
query = "SELECT sn,sender,message,phonenumber FROM messagesent where sentcode ='1' and billcode ='1' and route='7' order by sn limit 1"
#print(query)
mycursor.execute(query)
myresult = mycursor.fetchall()
for x in myresult:
sn = x[0];
sender = x[1];
message = x[2];
phonenumber= x[3];
print('Processing Records', x)
# Configure your message
sms_message = SmsMessage(
source="Python", # Replace this with your desired source name
body=message, # Write your message here
_from=sender,
to="+"+ phonenumber # Enter the number you are sending to
)
sms_messages = clicksend_client.SmsMessageCollection(messages=[sms_message])
try:
# Send an SMS message(s)
api_response = ast.literal_eval(api_instance.sms_send_post(sms_messages))
response_msg = api_response['response_msg']
message_id = api_response['data']['messages'][0]['message_id']
message_price= api_response['data']['messages'][0]['message_price']
carrier_country= api_response['data']['messages'][0]['country']
carrier= api_response['data']['messages'][0]['carrier']
message_status= api_response['data']['messages'][0]['status']
query = "update messagesent set sentcode ='2',result='0',track='1',messageid='{}',status='Awaiting Report',message_price='{}',carrier_country='{}',carrier='{}',message_status='{}' where sn = {} ".format(message_id,message_price,carrier_country,carrier,message_status,sn)
#print(query)
mycursor.execute(query)
mydb.commit()
except ApiException as e:
print("Exception when calling SMSApi->sms_send_post: %s\n" % e)
mycursor.close()
mydb.close()
print("press cltr^c to shut down")
time.sleep(20)
except Exception as error :
print("App shutdown", error);