Compare commits
No commits in common. "master" and "v0.1" have entirely different histories.
9
HISTORY
9
HISTORY
@ -1,12 +1,5 @@
|
||||
0.2 - 2014-08-17
|
||||
Changed properties from public to private and removed
|
||||
public keyword from the functions since this is the
|
||||
defualt anyway
|
||||
|
||||
0.1.1 - 2014-08-02
|
||||
Added two examples of how to use the class
|
||||
|
||||
0.1 - 2014-07-31
|
||||
First relase of the class
|
||||
|
||||
|
||||
Note: For more history information, please see the git log
|
||||
|
@ -37,10 +37,6 @@ Parameters for the sendSMS function in order:
|
||||
## Requirements ##
|
||||
The class requires PHP5 and the PHP5 cURL module (php5-curl on Debian systems).
|
||||
|
||||
## Examples ##
|
||||
In the examples directory are two easy to follow example on how this class can
|
||||
be used. Both examples should work out of the box as is.
|
||||
|
||||
## Copyright ##
|
||||
This class is written by Jack-Benny Persson and released under GNU GPL
|
||||
version 2.
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
|
||||
/*
|
||||
Version 0.2
|
||||
Version 0.1
|
||||
|
||||
Usage example:
|
||||
$MySMS = new Cellsynt("myuser", "mYpaSS", "alpha", "Test");
|
||||
@ -28,18 +28,18 @@
|
||||
|
||||
class Cellsynt
|
||||
{
|
||||
private $username;
|
||||
private $password;
|
||||
private $origType;
|
||||
private $originator;
|
||||
private $phone;
|
||||
private $concat;
|
||||
private $charset;
|
||||
private $type;
|
||||
private $expiry;
|
||||
private $msg;
|
||||
public $username;
|
||||
public $password;
|
||||
public $origType;
|
||||
public $originator;
|
||||
public $phone;
|
||||
public $concat;
|
||||
public $charset;
|
||||
public $type;
|
||||
public $expiry;
|
||||
public $msg;
|
||||
|
||||
function __construct($username, $password, $origType = "alpha",
|
||||
public function __construct($username, $password, $origType = "alpha",
|
||||
$originator = "Cellsynt", $concat = 6,
|
||||
$charset = "UTF-8", $type = "text")
|
||||
{
|
||||
@ -52,7 +52,7 @@ class Cellsynt
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
function sendSMS($phoneNr, $msg, $expiry = "")
|
||||
public function sendSMS($phoneNr, $msg, $expiry = "")
|
||||
{
|
||||
$this->msg = $msg;
|
||||
$this->phoneNr = $phoneNr;
|
||||
|
@ -1,78 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
A small example of what can be done with the cellcentClass.
|
||||
Here is a script that let's a user send SMS-messages from the command-line
|
||||
by giving two arguments to the script, the first one is the phone number,
|
||||
the second is the text message to be sent.
|
||||
Login information and originator text is set as static values here.
|
||||
*/
|
||||
|
||||
// the class is required...
|
||||
require ("../cellsyntClass.php");
|
||||
|
||||
// username and password information for the Cellsynt account and
|
||||
// the sender/originator
|
||||
$username = "myuser";
|
||||
$password = "sEcReT";
|
||||
$sender = "From CLI";
|
||||
|
||||
// run a sanity check
|
||||
sanitycheck();
|
||||
|
||||
// if we got past the sanity checks above, instantiate the class
|
||||
$cliSMS = new Cellsynt($username, $password, "alpha", $sender);
|
||||
|
||||
// put the arguments into variables for readability
|
||||
$phone = $argv[1];
|
||||
$message = $argv[2];
|
||||
|
||||
// call the sendSMS function with the phone number and message
|
||||
$status = $cliSMS->sendSMS($phone, $message);
|
||||
|
||||
// check the status of the message and print the result
|
||||
checkstatus();
|
||||
|
||||
// if we got to down here, something was wrong, exit with status code 1
|
||||
exit(1);
|
||||
|
||||
|
||||
function checkstatus()
|
||||
{
|
||||
global $status;
|
||||
// check for an OK message at the start of the line, in that case everything
|
||||
// was fine
|
||||
if (preg_match("/^OK/", $status))
|
||||
{
|
||||
print "Message was sent successfully. Status message reads:\n";
|
||||
print $status . "\n";
|
||||
exit(0);
|
||||
}
|
||||
// if there were no OK message, something didn't work
|
||||
else
|
||||
{
|
||||
print "Something didn't work out as expected. Status message reads:\n";
|
||||
print $status . "\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function sanitycheck()
|
||||
{
|
||||
global $argv;
|
||||
// check if user entered two arguments
|
||||
if (!isset($argv[1]) || !isset($argv[2]))
|
||||
{
|
||||
print "Usage: $argv[0] <phone nr> <'quoted text message'>\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// check if the phone number looks valid
|
||||
if (!preg_match("/\d{7,16}/", $argv[1]))
|
||||
{
|
||||
print "That dosen't look like a valid phone number\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1,49 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
An example of what the cellsyntClass can be used for.
|
||||
Here is a simple webpage from which one can send SMS-message by specifing
|
||||
phone number, text message and sender information.
|
||||
*/
|
||||
|
||||
// the class is required for this to work
|
||||
require ("../cellsyntClass.php");
|
||||
|
||||
// start the HTML
|
||||
print <<<_START_HTML_
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<title>Example SMS webpage</title>
|
||||
<meta charset="UTF-8" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Send SMS-message</h1>
|
||||
|
||||
<form action="$_SERVER[PHP_SELF]" method="post">
|
||||
Phone number:<input type="text" name="phone" size="18" maxlength="18"><br/>
|
||||
Message:<br/>
|
||||
<textarea name="message" cols="70" rows="15"></textarea><br/>
|
||||
Sender:<input type="text" name="sender" size="11" maxlength="11"><br/>
|
||||
<input type="submit" value="Send SMS"><br/>
|
||||
</form>
|
||||
_START_HTML_;
|
||||
|
||||
// check if the form has been submitted in which case we send the SMS
|
||||
if((isset($_POST['phone'])) || (isset($_POST['message'])) ||
|
||||
(isset($_POST['sender'])))
|
||||
{
|
||||
// make variables of the _POST array
|
||||
$phone = $_POST['phone'];
|
||||
$message = $_POST['message'];
|
||||
$sender = $_POST['sender'];
|
||||
|
||||
// instantiate class with $sender and hardcoded user and password
|
||||
$MySMS = new Cellsynt("myuser", "sEcReT", "alpha", "$sender");
|
||||
// call the sendSMS function and print the status-message on the webpage
|
||||
print "<p>" . $MySMS->sendSMS($phone, $message) . "</p>\n";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user