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

(Gerardo) #41

I uncomment line and gave me another error
Uncaught Twilio\Exceptions\TwilioException: Unknown subresource sms_messages

(Tony) #42


I am piggy-backing on this thread b/c my problem is very similar. Please let me know if it is best to start a new thread instead.

I have been learning about openemr for a few weeks now and I am really impressed. I am using OpenEMR 5.0.1 (7) on Ubuntu 18.04.2 for this learning instance and am now trying to see if I can get patient reminders to work with Twilio. I have an upgraded Twilio project w/ a number and sufficient credits. I have also carefully followed the wiki (

At the moment I only get a blank page when running “http://localhost/openemr/modules/sms_email_reminder/cron_sms_notification.php”. When I go to Administration>Other>Logs I don’t see any information created after I enter that address in my browser (I don’t know if there are other logs I should be looking at).

I’m wondering if anyone can help me with a next step in troubleshooting this. I see earlier in this thread @visolveemr links to a latest release of twilio-php. Should I try replacing the /var/www/openemr/modules/sms_email/reminder/twilio that I am using (which is from oemrtwilio/openemr/modules/sms_email_reminder/twilio at master · fkasmani/oemrtwilio · GitHub) with the files from the twilio-php linked by @visolveemr? Or is it likely that my problem is something else?

Thank you!

(Stephen Waite) #43

php error logs should be in /var/log/apache2/error.log

(Tony) #44

I got it to work. Which is amazing since I have zero coding knowledge. Hopefully I can explain what I did clearly enough so it will help others with the same problem.

I used the latest twilio-php mentioned earlier in this thread which apparently means you have to change all kinds of stuff.

First I had to change a few things in cron_sms_notification.php:

  1. mysql_query needs to change to mysqli_query, and this involves adding some parameters. Under “global $mysms;” I added a line: “$db = mysqli_connect(”[your server ip], [database user], [database password], [database name]);"
  2. The “$q=mysql_query…” line then is changed to “$q=mysqli_query($db, $sql);”
  3. In the next line down “mysql_fetch_assoc” needs to change to “mysqli_fetch_assoc”
  4. I think you also have to change the “sqlClose();” at the end of this file to “mysqli_close($db);”

As long as you have everything else copied perfectly from oemrtwilio/cron_sms_notification.php at master · fkasmani/oemrtwilio · GitHub your cron_sms_notification.php should be good to go.

The sendnotifications.php file is the one that really gave me trouble. This is what works for me:

/* 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 
 *   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 
//, and move it into the folder containing this 
// file.

require __DIR__ . '/twilio/Twilio/autoload.php';

// Use the REST API Client to make requests to teh Twilio REST API
use Twilio\Rest\Client;

// Your Account SID and Auth Token from
$sid = '<your account sid>';
$token = '<your account token>';

function sendtsms($AccountSid,$AuthToken,$from,$people,$body){

$client = new Client($sid, $token);

// 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";
      'from' => $from,
      'body' => $body
	echo "Sent message to $name";


This might all be quite obvious if you have some idea of what the heck PHP is and all that, but for me, not so much.
Maybe someone will see something that doesn’t look right, but so far as I can tell this is at least getting messages through via twilio.