Page 1 of 1

Send SMS txt to phones?

Posted: 2022-04-16 10:41
by mqley
Hi, say I want to txt message all people signed up. Would that be possible?

Re: Send SMS txt to phones?

Posted: 2022-04-16 16:59
by pbottcher
Hi,

there is no such function build-in AppGini. You may connect to an external service to acheive this, but need to code it.

Re: Send SMS txt to phones?

Posted: 2022-04-17 09:06
by mqley
Ok thanks, I thought as much. It would be too much of a project for me to code it. Let me know if you ever decide to code such a plugin though as I would be interested.

Re: Send SMS txt to phones?

Posted: 2022-04-18 07:11
by mqley
Hi again, just out of interest. Would you know of any 3rd party companies that AppGini could connect to? I appreciate there would be coding via the Appgini end, but would be interesting to make some progress toward the goal.

Re: Send SMS txt to phones?

Posted: 2022-04-18 07:24
by jsetzer
twilio.com is a well known company offering paid SMS gateway services (and other gateway services). There are many others on the market.

Re: Send SMS txt to phones?

Posted: 2022-04-18 10:57
by mqley
Great thanks. Actually thinking about it. Is it possible to send phone Notifications to Android/Apple. Presume that's an whole new debate/level?

Re: Send SMS txt to phones?

Posted: 2022-04-18 17:44
by pbottcher
Hi,

actually your need is not very clear, so it is not easy to help. Why cant you just use the mail function?

Re: Send SMS txt to phones?

Posted: 2022-04-18 19:51
by mqley
Hi, that's a good question - well I wanted something more instant, whereas email doesn't always get noticed.

Re: Send SMS txt to phones?

Posted: 2022-04-18 20:52
by mqley
That said, as it's in place already - it may well be ok. Was just interested in what was possible

Re: Send SMS txt to phones?

Posted: 2022-04-18 21:01
by jsetzer
Much is possible: immediate in-browser notification of logged in users, WhatsApp notification, Email or SMS. It depends on your requirements and budget.

Re: Send SMS txt to phones?

Posted: 2022-04-20 16:45
by Alisson
I've been using Twilio for a long time without any problems.
After creating an account with twilio and downloading their files.
Just add this to /hooks/tablename.php at the beginning of the file:

Code: Select all

 require_once $_SERVER["DOCUMENT_ROOT"]."/vendor/twilio-php-master/Twilio/autoload.php";
 use Twilio\Rest\Client;
and add this to the end:

Code: Select all

function sendSMS($data, $memberInfo){
  $staffPhone	= sqlValue("select custom2 from membership_users where memberID='{$data['username']}'");
  $sid = 'YOUR SID';
  $token = 'YOUR TOKEN';
  $client = new Client($sid, $token);
  $client->messages->create("$staffPhone",
  array('from' => 'YOUR TWILIO NUMBER HERE',
      'body' => "Body message here".
      "\n\n".
      "Field: {$data['field']}".
      "\n\n".
      "Thank you!!!")
   );
  break;
}
Then you can call sendSMS inside after_update, or after_insert:

Code: Select all

function yourTableName_after_update($data, $memberInfo, &$args){
  sendSMS($data, $memberInfo);
  return TRUE;
 }

Re: Send SMS txt to phones?

Posted: 2023-05-18 22:07
by hinoue
How do you loop through the list of phone numbers obtained from SQL with this function to send SMS to multiple recipients?

Re: Send SMS txt to phones?

Posted: 2023-05-19 07:14
by onoehring
Hi,

even as this should be easy to find online (google) ... try something like this

Code: Select all

$sqlString = "SELECT field1, field2 FROM yourtable;";
$sql_Result = sql($sqlString, $eo);
while ($row_Fields = db_fetch_assoc($sql_Result)) {
    DO SOMETHING HERE WITH $row_Fields['field1'] AND $row_Fields['field2']
}
Olaf

Re: Send SMS txt to phones?

Posted: 2023-05-19 23:53
by hinoue
Thank you-- ended up using foreach (explode(",", $toNumbers) as $toNumber) in order to pass each phone number from a table.