| 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/sms4real.com/wwwroot/test/http/ |
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 VoiceMessage
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.VoiceApi(clicksend_client.ApiClient(configuration))
# VoiceMessageCollection | VoiceMessageCollection model
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 Robo Call 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,language,voicetype,message,phonenumber FROM messagesentsplittedvoice where sentcode ='1' and billcode ='1' order by sn limit 1"
#print(query)
mycursor.execute(query)
myresult = mycursor.fetchall()
for x in myresult:
sn = x[0]
language = x[1]
voicetype = x[2]
message = x[3]
phonenumber= x[4]
print('Processing Records', x)
# Configure your message
voice_message=VoiceMessage(source="python",
body=message,
to="+"+phonenumber,
lang=language,
voice=voicetype,
schedule="",
custom_string="",
require_input=1,
machine_detection=1,country="united kingdom")
voice_messages = clicksend_client.VoiceMessageCollection(messages=[voice_message])
try:
# Send Robo Call(s)
api_response = ast.literal_eval(api_instance.voice_send_post(voice_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 messagesentsplittedvoice 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);