No sms are sent with twilio / No se envian sms con twilio

cmswest wrote on Tuesday, November 22, 2016:

please set SMS Notification Hours to 1 in the globals, save and recheck an appt within the next hour, thank you

arielimlauer wrote on Tuesday, November 22, 2016:

No need to change anything on sendnotifications.php?
Now I have this:


<?php /* Send an SMS using Twilio. You can run this file 3 different ways: * * - Save it as sendnotifications.php and at the command line, run * php sendnotifications.php * * - Upload it to a web host and load mywebhost.com/sendnotifications.php * in a web browser. * - Download a local server like WAMP, MAMP or XAMPP. Point the web root * directory to the folder containing this file, and load * localhost:8888/sendnotifications.php in a web browser. */ // Include the PHP Twilio library. You need to download the library from // twilio.com/docs/libraries, and move it into the folder containing this // file. require "twilio/Services/Twilio.php"; function sendtsms($AccountSid,$AuthToken,$from,$people,$body){ // Set our AccountSid and AuthToken from twilio.com/user/account //$AccountSid = "XXXXXXXXXXXXXXXXXXX"; //$AuthToken = "XXXXXXXXXXXXXXXXXX"; // Instantiate a new Twilio Rest Client //$client = new Services_Twilio($AccountSid, $AuthToken); /* Your Twilio Number or Outgoing Caller ID */ //$from = '+919924927267'; // make an associative array of server admins. Feel free to change/add your // own phone number and name here. /*$people = array( "9924927267" => "Johnny", "4158675310" => "Helen", "4158675311" => "Virgil", );*/ // Iterate over all admins in the $people array. $to is the phone number, // $name is the user's name foreach ($people as $to => $name) { // Send a new outgoing SMS */ //$body = "Bad news $name, the server is down and it needs your help"; $client->account->sms_messages->create($from, $to, $body); echo "Sent message to $name"; } } ?>

cmswest wrote on Tuesday, November 22, 2016:

no but here’s a working copy

arielimlauer wrote on Tuesday, November 22, 2016:

and that file does not carry any settings?
Thanks for the patience :slight_smile:

arielimlauer wrote on Tuesday, November 22, 2016:

Strange is that is not allowing me to send reminders (email) in coming days, for example tomorrow. When mysql and php Deden be synchronized?

cmswest wrote on Tuesday, November 22, 2016:

no settings in that file

arielimlauer wrote on Wednesday, November 23, 2016:

Hello,
I feel I’m so close to you send an sms do not want to leave this. no longer about where to find the error, When I run the cron got this message:

0 DEBUG :: user = username sms
Total 2 Records Found ----- DEBUG: cron_sms: patient found = Ariel DEBUG :: checkdate = 11.23.2016, app_date = 23.11.2016 10:45:00, remain_hour apptime = 1479908700 = -3 - CRON_TIME = 0 ----- DEBUG: cron_sms: patient found = Ariel DEBUG :: checkdate = 23.11.2016, app_date = 23.11.2016 15:00:00, remain_hour apptime = 1479924000 = 1 - CRON_TIME = 0

ERROR: could not disconnect from server mysql link

C: \ xampp \ htdocs \ OpenEMR \ modules \ sms_email_reminder \ cron_sms_notification.php at 127: SQLClose

But do not send the sms, I have a very similar to the electronic mail message, but are sent correctly via mercury.

Greetings.

arielimlauer wrote on Wednesday, November 23, 2016:

I think I found the problem! Still no solution :frowning:
Now I appears in the log of SMS the following Cron

SMS ======================== || 11/23/2016 14:35:19 =========================
SEND NOTIFICATION BEFORE: 0 || Cronjob RUN EVERY: 0 || APPDATETIME: 23/11/2016 10:45:00 || REMAINING APP HOUR: -4 || SEND ALERT AFTER: -4

“Send alert after -4” ???

cmswest wrote on Wednesday, November 23, 2016:

hi Ariel, there’s a new setting, please set SMS Notification Hours to 1 in the globals, save and recheck an appt within the next hour, thank you

arielimlauer wrote on Thursday, November 24, 2016:

Hello how are you!!! It looks like everything is fine, both in the log of cron_sms_notification and what the browser displays.

========== SMS || 2016-11-24 14:33:25 ==========================
SEND NOTIFICATION BEFORE: 1 || CRONJOB RUN EVERY: 1 || APPDATETIME: 2016-11-24 16:15:00 || REMAINING APP HOUR: 1 || SEND ALERT AFTER: 0 || ALERT SENT SUCCESSFULLY TO + 54XXXXXXXXXXX

Welcome to EMR GROUP 1 … SMS
==================================== ================

But the SMS does not reach the mobile phone. I’m using my Twilio TEST credentials and the “magic number” I use is +15005550006. I bought 20 dollars in text messages, if that was the problem, but no. I would like this test to work, so buy a US phone number and use productive credentials and not test. (I am correct with the purchase of the number to send sms to Argentina?)

Greetings and thank you very much!

arielimlauer wrote on Friday, November 25, 2016:

alguna idea?

cmswest wrote on Friday, November 25, 2016:

nice, that’s right, the test account does not actually send the sms message to a real phone number

i need your help, i followed all instructions in forums and website, inclus i used the same file cron_sms_notification.php attached in this topics, i have credit in my twilio account whit my Account Sid, Auth Token and From name (a number phone what i payed) in my server amazon with PHP7 changed al codes carefully and the file step just showme an message (Error in SMS authorization! (ERR: 108, Invalid or missing api_id)

and i put all codes correctly, then when i visit /var/spool/mail/ nano ec2-user i see this mesage


could you helpe what can i do?
thanks guys

@geromoss,
We have integrated twilio with OpenEMR using PHP 7.0 and its working fine.
Can you please share error log to investigate the issue further.

Thanks,
ViSolve

which one the correct plug in to install Twilio with openEMR, maybe I installed a older version

@geromoss,
We have tried with the latest release. For your reference, we have shared the link

Kindly let us know, if you have any clarifications.

Thanks,
ViSolve

nice!i instaled the last plugin twilio and the error changed! now i have this new error and i found where is the problem, my server has installed php version 7 and the file cron_sms_notificaction.php has old function deprecaded to Mysql for example
global $mysms;
$sql=“select * from globals where gl_name in (‘TWILIO_ACCOUNT_SID’,‘TWILIO_AUTHTOKEN’,‘TWILIO_FROM’)”;
$q=mysql_query($sql); <----- here
while($r=mysql_fetch_assoc($q)){ <-----here too
if($r[‘gl_name’]==‘TWILIO_ACCOUNT_SID’)
$AccountSid=$r[‘gl_value’];
if($r[‘gl_name’]==‘TWILIO_AUTHTOKEN’)
$AuthToken=$r[‘gl_value’];
if($r[‘gl_name’]==‘TWILIO_FROM’)
$from=$r[‘gl_value’];

how can i changed that ?


@geromoss,
In php 7, mysql_query function is removed.
Now either you can try with mysqli_query or OpenEMR library functions(sqlStatement,sqlFetchArray).

Thanks,
ViSolve

ok guys, what i did was: i upload the last SDK twilio in server, the last SDK have different metohd por example, $client = new Services_Twilio($AccountSid, $AuthToken);
for : $client = new Client($AccountSid,$AuthToken);

I changed many codes in php and don’t send it SMS, I think the problem is in the file sendnotificactions.php because everybody have differents versions to pull SMS message and the wiki page is obsolet because twilio changed many functions to push SMS, if you can help me, wich your file sendnotificagion.php? to compare where is the problem i’ll gratefully forever.
this is my file sendnotificaciont.php

<?php /* Send an SMS using Twilio. You can run this file 3 different ways: * * - Save it as sendnotifications.php and at the command line, run * php sendnotifications.php * * - Upload it to a web host and load mywebhost.com/sendnotifications.php * in a web browser. * - Download a local server like WAMP, MAMP or XAMPP. Point the web root * directory to the folder containing this file, and load * localhost:8888/sendnotifications.php in a web browser. */ // Include the PHP Twilio library. You need to download the library from // twilio.com/docs/libraries, and move it into the folder containing this // file. //require "Services/Twilio.php"; //require "twilio/Services/Twilio.php"; require __DIR__ . '/Twilio/autoload.php'; use Twilio\Rest\Client; function sendtsms($AccountSid,$AuthToken,$from,$people,$body){ // Instantiate a new Twilio Rest Client //$client = new Services_Twilio($AccountSid, $AuthToken); $client = new Client($AccountSid,$AuthToken); /* Your Twilio Number or Outgoing Caller ID */ $from = '+19413557341'; // make an associative array of server admins. Feel free to change/add your // own phone number and name here. /*$people = array( "9924927267" => "Johnny", "4158675310" => "Helen", "4158675311" => "Virgil", );*/ // Iterate over all admins in the $people array. $to is the phone number, // $name is the user's name foreach ($people as $to => $name) { // Send a new outgoing SMS */ //$body = "Bad news $name, the server is down and it needs your help"; //$client->account->sms_messages->create($from, $to, $body); $client->messages->create($to,array('from' => '+19416667341', 'body' => "Enviado desde MedidocEMR tienes una cita agendada!")); //$client->messages->create($from,$to,$body); echo "Sent message to $name"; } } ?>

@geromoss,
Have you trigger the application using
http://IP_NUMBER/openemr/modules/sms_email_reminder/cron_sms_notification.php

Please uncomment the below line in the sendnotifications.php
//$client->account->sms_messages->create($from, $to, $body);

Thanks,
ViSolve