Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Wikxen committed Dec 12, 2017
2 parents c882b69 + 293daf5 commit 93e8854
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 164 deletions.
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# SMSDemo
A demo website showing what you can do with the iP.1 PHP SDK in very little time.

A simple secret santa app by SMS using the iP.1 PHP SDK.

## Contributors
* **Hannes Kindströmmer** - _Initial work_

### Thanks to
* [Unsplash](https://unsplash.com/) for providing the background image
* **Erik Wikström**

## License
This software demo is licensed under the MIT license.
Binary file removed background.jpg
Binary file not shown.
13 changes: 10 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
{
"name": "ip1sms/smsdemo",
"description": "A frontend demo using the ip1-php-sdk",
"name": "wikxen/sms-secret-santa",
"description": "A secret santa app using the ip1-php-sdk",
"version": "1.0.0",
"type": "project",
"license": "MIT",
"authors": [
{
"name": "Erik Wikström",
"email": "wikxen@gmail.com",
"homepage": "http://wikxen.se",
"role": "Developer"
},
{
"name": "Hannes Kindströmmer",
"email": "hannes@kindstrommer.se",
"homepage": "http://kindstrommer.se",
"role": "Developer"
"role": "Original Work"
}
],
"minimum-stability": "beta",
Expand Down
93 changes: 0 additions & 93 deletions index.php

This file was deleted.

63 changes: 0 additions & 63 deletions sendsms.php

This file was deleted.

45 changes: 45 additions & 0 deletions webhook.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
use IP1\RESTClient\Core\Communicator;
use IP1\RESTClient\SMS\OutGoingSMS;

require_once('vendor/autoload.php');

// Initial setup
$config = json_decode(file_get_contents('config.json'), true);
$api = new Communicator($config['account'], $config['token']);

// handle parameters
$sender = $_GET["sender"];
$msg = $_GET["text"];

// pick action
if (strtolower(substr($msg, 0, 5)) == "santa") { // signup
// get name from message
$name = substr($msg, 6);
// print name and number to file
$printed = file_put_contents('santa.txt', $sender . ";" . $name . PHP_EOL, FILE_APPEND | LOCK_EX);
// send response
$sms = new OutGoingSMS("Tomten", "Du är med som " . $name . "!");
$sms->addNumber($sender);
$api->add($sms);
} else if (strtolower(substr($msg, 0, 2)) == "go") { // send
// Parse the file string into an array of people
$file = file_get_contents("santa.txt");
$people = explode(PHP_EOL, $file);
array_pop($people);
$people = array_unique($people);
shuffle($people);

// Loop through the numbers sending
// $i sends an SMS to $i+1
for ($i=0; $i < count($people); $i++) {
$sender = explode(";", $people[$i]);
$recipient = explode(";", $i != count($people) - 1 ? $people[$i + 1] : $people[0]);

$sms = new OutGoingSMS($sender[0], "Hej " . $recipient[1] . "!\nDu fick mig. Köp något bra nu för ungefär 100 kr.\n// " . $sender[1]);
$sms->addNumber($recipient[0]);
$api->add($sms);
}
}

echo "OK";

0 comments on commit 93e8854

Please sign in to comment.