I have a python file for sending automatic sms, as I show here:
myresult = cursor.fetchall()
for linha in myresult:
PrimeiroNome = linha[0]
UltimoNome = linha[1]
respons = linha[2]
contact = linha[3]
Data = linha[4]
Datasms = linha[5]
Hora = linha[6]
title = linha[7]
if __name__ == "__main__":
url ="xxxxxxxxxxxxxxxxxxxxxxxxx"
usrPass = "xxxxxxxxxxxxxxxxxxxx"
data = json.dumps({
u"to":[contact],
u"from":u"xxxxxxxxxxx",
u"message":u"Informamos que tem visita agendada no dia {} às {}, com o Utente {} {}. Caso não possa comparecer, avise-nos pf.".format(
Datasms, Hora, PrimeiroNome, UltimoNome),
u"encoding":u"gsm-pt",
u"parts":u"2"
})
b64Val = base64.b64encode(usrPass)
headers=["Accept:Application/json","Authorization:Basic %s"%b64Val]
c = pycurl.Curl()
c.setopt(pycurl.URL, url)
c.setopt(pycurl.HTTPHEADER,headers)
c.setopt(pycurl.POST, 1)
c.setopt(pycurl.POSTFIELDS, data)
c.setopt(pycurl.SSL_VERIFYHOST, 0)
c.setopt(pycurl.SSL_VERIFYPEER, 0)
c.perform()
http_code = c.getinfo(pycurl.HTTP_CODE)
The file path is /var/www/html/wp-content/themes/sparkling/smsvistadia.py. I intend that when inserting into the database in php that you execute this file and send the sms if you fulfill the condition.
I'm trying this way:
$sql = "INSERT INTO AgendaVisitas(title, respons, contact, title1, contact1, titl1, contac1, start, end, Acamado, DataRegisto, colaborador, week) values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$sth = $conn->prepare($sql )->execute([$title, $respons, $contact, $title1, $contact1, $titl, $contac, $start, $end, $Acamd, $DataRegisto, $colaborador, $week]);
if(DATE($DataRegisto) == DATE($start)){
$command = escapeshellcmd('/var/www/html/wp-conten/themes/sparkling/smsvistadia.py');
$output = shell_exec($command);
}
But when I do the insert in order to fulfill the condition it does not execute the action of the python file which is to send the sms. Can you help?