Hello Aka,
I have never tried sending SMS with SC, but I have seen some libraries that are not difficult to use. For example:
- Clickatell: It is robust and is known in a ton of countries. With this guy you can:
- Using email to send SMS, this is cool if you do not want to dirt your hands in code.
- Using an API: I would like to tell you more about this, but the developer’s guide is closed for visitors.
- Twilio: I have seen its docs and It looks pretty easy to integrate.
For both cases you need to register and obtain some tokens to be used in your side. Let me show you and example how Twilio could be integrated in SC.
- Download Twilio-PHP library from their page. Upload them in ScriptCase using Tools -> External Libraries. I will assume that this library will be named to “twilio”.
- Create a blank application named “SEND_SMS”.
- Import Twilio library using ScriptCase macro, the main file is Services/Twilio.php:
sc_include_library("sys", "twilio","Services/Twilio.php", true, true);
- Now, using your credentials an library to send a message:
// your credentials, this tokes are found in you account
$AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$AuthToken = "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY";
// Preparing the library
$client = new Services_Twilio($AccountSid, $AuthToken);
// Details of the new SMS
$name = "O'Ren";
$number = "+14158675309";
// Sending a message
$sms = $client->account->messages->sendMessage($number, "Hey {$name}, Monkey Party at 6PM. Bring Bananas!");
// Display a confirmation message on the screen
echo "Sent message to {$name}";
Now, try to access SEND_SMS in browser to test the service. Above I am setting $name and $number directly, but you can pass that data via $_POST, or import the library in your applications and send message from events.