Skip to content

Instantly share code, notes, and snippets.

View twilioforkwc's full-sized avatar

Twilio for KDDI Web Communications twilioforkwc

View GitHub Profile
@twilioforkwc
twilioforkwc / get-parent-call-sid.php
Created October 2, 2014 05:16
get-parent-call-sid.php
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('../Services/Twilio.php'); // Loads the library
$sid = "ACxxxxxxxxxx";
$token = "yyyyyyyyyyyyyy";
$client = new Services_Twilio($sid, $token);
$call = $client->account->calls->get("CAxxxxxxxxxxx");
echo $call->parent_call_sid;
<?php
header("content-type: text/xml");
// Connect to MySQL, and connect to the Database
mysql_connect('DB URL', 'ID', 'PWD') or die(mysql_error());
mysql_select_db('database') or die(mysql_error());
// 発信者番号を取得します。
$tel_from = $_POST['From'];
// 録音ファイルのURLを取得します。
<?php
header("content-type: text/xml");
?>
<Response>
<?PHP if (empty($_POST["Digits"])): ?>
<Say language="ja-jp">サンタさんにメッセージをおくるには 1を, メッセージの再生は 2を, 押してください。</Say>
<Gather numDigits="1" timeout="30" />
<?PHP elseif ($_POST["Digits"] == "1"): ?>
<Say language="ja-jp">録音完了後, 電話器のボタンをどれか 押してください。</Say>
<Record action="santa.php" />
<?php
header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8" ?>';
$key = $_REQUEST['Digits'];
?>
<Response>
<?php
if ($key == '1234')
{
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Gather action="room-check.php" numDigits="4">
<Say language="ja-jp">ルーム番号を4桁で入力してください。</Say>
</Gather>
<!-- 入力に間違いがあるとリトライします。 -->
<Redirect />
</Response>
<Response>
<Say language="ja-jp">Twilioカンファレンスへようこそ!</Say>
<Dial>
<Conference>twilioConferenceRoom</Conference>
</Dial>
</Response>
<Response>
<Say language="ja-jp">Twilioカンファレンスへようこそ!</Say>
<Dial>
<Conference waitUrl="https://api.twilio.com/Cowbwell.mp3">twilioConferenceRoom</Conference>
</Dial>
</Response>
@twilioforkwc
twilioforkwc / twiml-get-call.php
Last active September 29, 2015 06:08
twiml-get-call.php
<?php
require('../Services/Twilio.php');
$account_sid = "ACxxxxxxxxxx"; // Twilio account sid
$auth_token = "yyyyyyyyyyyyy"; // Twilio auth token
$client = new Services_Twilio($account_sid, $auth_token);
$call = $client->account->calls->create(
'+8150xxxxyyyy', // Twilio電話番号
@twilioforkwc
twilioforkwc / incoming_tel_number_update.php
Last active September 29, 2015 02:29
incoming_tel_number_update.php
<?php
require_once('../Services/Twilio.php'); // Loads the library
// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACxxxxxxxxxxxx";
$token = "yyyyyyyyyyyy";
$client = new Services_Twilio($sid, $token);
foreach ($client->account->incoming_phone_numbers as $number) {
if ( $number->phone_number == "+8150xxxxyyyy") {
<?php
require('../Services/Twilio.php');
$account_sid = "ACXXXXXX"; // Account Sid
$auth_token = "YYYYYY"; // Auth Token
$client = new Services_Twilio($account_sid, $auth_token);
$message = $client->account->messages->sendMessage(
'+1xxxxyyyyy', // From a Twilio number in your account
'+8180xxxxyyyy', // Text any number