Skip to content

Commit

Permalink
Added Twilio Calls API. Added Twilio API page.
Browse files Browse the repository at this point in the history
  • Loading branch information
AllAboutEE committed Mar 24, 2015
1 parent 6aba229 commit fcb70c6
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 30 deletions.
6 changes: 6 additions & 0 deletions app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ handlers:
- url: /twilio/Messages.*
script: /twilio/Messages.php

- url: /twilio/Calls.*
script: /twilio/Calls.php

- url: /twilio.html
script: twilio.html

- url: /bootstrap-3.3.4-dist
static_dir: bootstrap-3.3.4-dist

Expand Down
30 changes: 1 addition & 29 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,40 +31,12 @@ <h1>IoT HTTPS Relay</h1>

<h2>Supported APIs:</h2>
<ul class="list-group">
<li class="list-group-item">Twilio (SMS only at this time)</li>
<li class="list-group-item"><a href="twilio.html">Twilio (SMS and Voice Calls)</a></li>
</ul>
<p>
Submit API requests as issues with an "enhancement" label to
<a href="https://github.com/AllAboutEE/iot-https-relay">GitHub IoT HTTPS Relay</a>
</p>

<h2>Twilio SMS(Text Messaging)</h2>

<p>
To Use the Twilio SMS relay, simply send an HTTP POST request like the following.
<br/> Where the token and sid are provided to you by Twilio. The "From" number must be your Twilio provided number.
The "To" number can be any number, but it can only be your verified number if you are using Twilio's free service.
</p>
<pre>
<code>
POST /twilio/Messages.json HTTP/1.1
Host: iot-https-relay.appspot.com
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: xxx

token=xxxxxx&From=15558689998&To=19998675584&Body=myURLEncodedMessage&sid=xxxxxx

</code>
</pre>

<h3><span class="label label-default">Example</span> Twilio SMS (Text Messaging) With ESP8266 and NodeMcu</h3>
<script src="https://gist.github.com/AllAboutEE/6fe3ac554caaa2e3b450.js"></script>
</div>

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="bootstrap-3.3.4-dist/js/bootstrap.min.js"></script>
</body>
</html>
54 changes: 54 additions & 0 deletions twilio.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>IoT HTTPS Relay</title>

<!-- Bootstrap -->
<link href="bootstrap-3.3.4-dist/css/bootstrap.min.css" rel="stylesheet">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<h1>IoT HTTPS Relay</h1>
<p>
An API that acts as a relay for IoT devices that do not support HTTPS i.e. you can use HTTPS APIs using HTTP
</p>
<div class="alert alert-warning" role="alert">
<strong>Warning!</strong> Please be sure to understand the security issues of using this relay app and use at your own risk.
</div>

<p><a href="https://github.com/AllAboutEE/iot-https-relay">Fork me on GitHub</a></p>

<h1 class="page-header">Twilio</h1>
<p>
<a href="https://www.twilio.com/">Twilio</a> is a voice and SMS(Text messaging) communication API.
You can use this API to call and send textmessages to phones from your IoT devices.
</p>

<h4>Click on the links below to get started.</h4>
<div class="list-group">
<a href="http://allaboutee.com/2015/03/24/esp8266-phone-calls-with-twilio-api/" class="list-group-item">ESP8266 SMS (NodeMcu)</a>
<a href="http://allaboutee.com/2015/03/24/es8266-text-messages-with-twilio-and-nodemcu/" class="list-group-item">ESP8266 Calls (NodeMcu)</a>
<a href="#arduino-sms" class="list-group-item">Arduino and ESP8266 SMS (work in progress)</a>
<a href="http://allaboutee.com/2015/03/23/esp8266-and-arduino-phone-calls-with-twilio-api/" class="list-group-item">Arduino and ESP8266 Calls</a>
</div>

</div>

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="bootstrap-3.3.4-dist/js/bootstrap.min.js"></script>
</body>
</html>
22 changes: 22 additions & 0 deletions twilio/Calls.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

require('twilio-php/Services/Twilio.php');

$from = $_POST['From'];
$to = $_POST['To'];
$body = $_POST['Body'];
$sid = $_POST['sid'];
$token = $_POST['token'];

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

$call = $client->account->calls->create(
$from,
$to,
'http://twimlets.com/echo?Twiml=%3CResponse%3E%3CSay%3E'.urlencode($body).'%3C%2FSay%3E%3C%2FResponse%3E'

);


print $call->status;

2 changes: 1 addition & 1 deletion twilio/Messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
$body
);

print $message->sid;
print $message->status;



0 comments on commit fcb70c6

Please sign in to comment.